forked from tweag/nickel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
52 lines (38 loc) · 1.27 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
{
inputs.nixpkgs.url = "nixpkgs/nixos-20.03";
inputs.import-cargo.url = "github:edolstra/import-cargo";
outputs = { self, nixpkgs, import-cargo }:
with import nixpkgs { system = "x86_64-linux"; };
with pkgs;
let
buildPackage = { isShell }: stdenv.mkDerivation {
name = "nickel-${lib.substring 0 8 self.lastModifiedDate}-${self.shortRev or "dirty"}";
buildInputs =
[ rustc
cargo
] ++ (if isShell then [
rustfmt
clippy
] else [
(import-cargo.builders.importCargo {
lockFile = ./Cargo.lock;
inherit pkgs;
}).cargoHome
]);
src = if isShell then null else self;
buildPhase = "cargo build --release --frozen --offline";
doCheck = true;
checkPhase = "cargo test --release --frozen --offline";
installPhase =
''
mkdir -p $out
cargo install --frozen --offline --path . --root $out
rm $out/.crates.toml
'';
};
in {
defaultPackage.x86_64-linux = buildPackage { isShell = false; };
checks.x86_64-linux.build = self.defaultPackage.x86_64-linux;
devShell.x86_64-linux = buildPackage { isShell = true; };
};
}