Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Add Nix Flake #121

Merged
merged 1 commit into from
May 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

76 changes: 76 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
};

outputs = {
self,
nixpkgs,
}: let
inherit
(builtins)
substring
;
inherit
(nixpkgs.lib)
genAttrs
optionals
;

eachSystem = f:
genAttrs
[
"aarch64-darwin"
"aarch64-linux"
"x86_64-darwin"
"x86_64-linux"
]
(system: f nixpkgs.legacyPackages.${system});

rev = fallback:
if self ? rev
then substring 0 8 self.rev
else fallback;

packageFor = pkgs:
pkgs.rustPlatform.buildRustPackage {
pname = "typst-lsp";
version = rev "00000000";

src = self;

cargoLock = {
lockFile = ./Cargo.lock;
allowBuiltinFetchGit = true;
};

buildInputs = optionals pkgs.stdenv.isDarwin [
pkgs.darwin.apple_sdk.frameworks.CoreServices
];
};
in {
devShells = eachSystem (pkgs: {
default = pkgs.mkShell {
packages = with pkgs; [
cargo
clippy
rust-analyzer
rustc
rustfmt
nodejs
];

buildInputs = optionals pkgs.stdenv.isDarwin [
pkgs.darwin.apple_sdk.frameworks.CoreServices
pkgs.libiconv
];

RUST_SRC_PATH = pkgs.rustPlatform.rustLibSrc;
};
});

packages = eachSystem (pkgs: {
default = packageFor pkgs;
});
};
}