runnable flake

This commit is contained in:
Anthony Cicchetti 2023-12-01 16:14:36 -05:00
parent bf60586c80
commit 1049feb012

View file

@ -23,9 +23,16 @@
}; };
}; };
outputs = { self, nixpkgs, crane, fenix, flake-utils, advisory-db, ... }: outputs = {
flake-utils.lib.eachDefaultSystem (system: self,
let nixpkgs,
crane,
fenix,
flake-utils,
advisory-db,
...
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system}; pkgs = nixpkgs.legacyPackages.${system};
inherit (pkgs) lib; inherit (pkgs) lib;
@ -38,9 +45,11 @@
inherit src; inherit src;
strictDeps = true; strictDeps = true;
buildInputs = [ buildInputs =
[
# Add additional build inputs here # Add additional build inputs here
] ++ lib.optionals pkgs.stdenv.isDarwin [ ]
++ lib.optionals pkgs.stdenv.isDarwin [
# Additional darwin specific inputs can be set here # Additional darwin specific inputs can be set here
pkgs.libiconv pkgs.libiconv
]; ];
@ -49,7 +58,8 @@
# MY_CUSTOM_VAR = "some value"; # MY_CUSTOM_VAR = "some value";
}; };
craneLibLLvmTools = craneLib.overrideToolchain craneLibLLvmTools =
craneLib.overrideToolchain
(fenix.packages.${system}.complete.withComponents [ (fenix.packages.${system}.complete.withComponents [
"cargo" "cargo"
"llvm-tools" "llvm-tools"
@ -62,11 +72,12 @@
# Build the actual crate itself, reusing the dependency # Build the actual crate itself, reusing the dependency
# artifacts from above. # artifacts from above.
my-crate = craneLib.buildPackage (commonArgs // { my-crate = craneLib.buildPackage (commonArgs
// {
inherit cargoArtifacts; inherit cargoArtifacts;
cargoExtraArgs = "-p cli";
}); });
in in {
{
checks = { checks = {
# Build the crate as part of `nix flake check` for convenience # Build the crate as part of `nix flake check` for convenience
inherit my-crate; inherit my-crate;
@ -77,12 +88,14 @@
# Note that this is done as a separate derivation so that # Note that this is done as a separate derivation so that
# we can block the CI if there are issues here, but not # we can block the CI if there are issues here, but not
# prevent downstream consumers from building our crate by itself. # prevent downstream consumers from building our crate by itself.
my-crate-clippy = craneLib.cargoClippy (commonArgs // { my-crate-clippy = craneLib.cargoClippy (commonArgs
// {
inherit cargoArtifacts; inherit cargoArtifacts;
cargoClippyExtraArgs = "--all-targets -- --deny warnings"; cargoClippyExtraArgs = "--all-targets -- --deny warnings";
}); });
my-crate-doc = craneLib.cargoDoc (commonArgs // { my-crate-doc = craneLib.cargoDoc (commonArgs
// {
inherit cargoArtifacts; inherit cargoArtifacts;
}); });
@ -104,7 +117,8 @@
# Run tests with cargo-nextest # Run tests with cargo-nextest
# Consider setting `doCheck = false` on `my-crate` if you do not want # Consider setting `doCheck = false` on `my-crate` if you do not want
# the tests to run twice # the tests to run twice
my-crate-nextest = craneLib.cargoNextest (commonArgs // { my-crate-nextest = craneLib.cargoNextest (commonArgs
// {
inherit cargoArtifacts; inherit cargoArtifacts;
partitions = 1; partitions = 1;
partitionType = "count"; partitionType = "count";
@ -113,13 +127,15 @@
packages = { packages = {
default = my-crate; default = my-crate;
my-crate-llvm-coverage = craneLibLLvmTools.cargoLlvmCov (commonArgs // { my-crate-llvm-coverage = craneLibLLvmTools.cargoLlvmCov (commonArgs
// {
inherit cargoArtifacts; inherit cargoArtifacts;
}); });
}; };
apps.default = flake-utils.lib.mkApp { apps.default = flake-utils.lib.mkApp {
drv = my-crate; drv = my-crate;
name = "cli";
}; };
devShells.default = craneLib.devShell { devShells.default = craneLib.devShell {
@ -132,7 +148,7 @@
# Extra inputs can be added here; cargo and rustc are provided by default. # Extra inputs can be added here; cargo and rustc are provided by default.
packages = [ packages = [
pkgs.sd pkgs.sd
# pkgs.ripgrep pkgs.alejandra
]; ];
}; };
}); });