1
1
mirror of https://github.com/tweag/nickel.git synced 2024-11-10 10:46:49 +03:00
nickel/flake.nix

59 lines
1.6 KiB
Nix
Raw Normal View History

2020-07-03 15:22:21 +03:00
{
2020-10-27 14:17:16 +03:00
inputs.nixpkgs.url = "nixpkgs/nixos-20.09";
2020-07-03 15:22:21 +03:00
inputs.import-cargo.url = "github:edolstra/import-cargo";
outputs = { self, nixpkgs, import-cargo }:
let
2020-10-27 14:32:05 +03:00
systems = [ "x86_64-linux" "x86_64-darwin" ];
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system);
# Memoize nixpkgs for different platforms for efficiency.
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
buildPackage = { isShell, system }: with nixpkgsFor.${system}; stdenv.mkDerivation {
2020-07-03 15:22:21 +03:00
name = "nickel-${lib.substring 0 8 self.lastModifiedDate}-${self.shortRev or "dirty"}";
buildInputs =
[ rustc
cargo
] ++ (if isShell then [
rustfmt
clippy
2020-07-03 15:22:21 +03:00
] 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 {
2020-10-27 14:32:05 +03:00
defaultPackage = forAllSystems (system: buildPackage { inherit system; isShell = false; });
2020-07-03 15:22:21 +03:00
2020-10-27 14:32:05 +03:00
checks = forAllSystems (system: {
build = self.defaultPackage.${system};
});
2020-07-03 15:22:21 +03:00
2020-10-27 14:32:05 +03:00
devShell = forAllSystems (system: buildPackage { inherit system; isShell = true; });
2020-07-03 15:22:21 +03:00
};
}