Update default template to work on macos (#157)

Fixes #156
This commit is contained in:
Mitch Tishmack 2022-11-09 20:25:18 -06:00 committed by GitHub
parent 2e24bc6591
commit 074825a9e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,21 +24,25 @@
inherit system;
};
inherit (pkgs) lib;
inherit (pkgs) lib stdenv;
craneLib = crane.lib.${system};
src = craneLib.cleanCargoSource ./.;
# If one needs to customize the build environment mostly only needed for
# macos dependencies or frameworks.
buildInputs = [ ] ++ lib.optionals stdenv.isDarwin (lib.attrVals [ "libiconv" ] pkgs);
# Build *just* the cargo dependencies, so we can reuse
# all of that work (e.g. via cachix) when running in CI
cargoArtifacts = craneLib.buildDepsOnly {
inherit src;
inherit src buildInputs;
};
# Build the actual crate itself, reusing the dependency
# artifacts from above.
my-crate = craneLib.buildPackage {
inherit cargoArtifacts src;
inherit cargoArtifacts src buildInputs;
};
in
{
@ -53,7 +57,7 @@
# we can block the CI if there are issues here, but not
# prevent downstream consumers from building our crate by itself.
my-crate-clippy = craneLib.cargoClippy {
inherit cargoArtifacts src;
inherit cargoArtifacts src buildInputs;
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
};
@ -75,7 +79,7 @@
# Consider setting `doCheck = false` on `my-crate` if you do not want
# the tests to run twice
my-crate-nextest = craneLib.cargoNextest {
inherit cargoArtifacts src;
inherit cargoArtifacts src buildInputs;
partitions = 1;
partitionType = "count";
};