refactor(flakes): commonize args

This commit is contained in:
Harsh Shandilya 2023-04-26 04:46:36 +00:00
parent e0565a316c
commit 98bedea6f3
1 changed files with 29 additions and 25 deletions

View File

@ -3,11 +3,14 @@
inputs = {
nixpkgs = {url = "github:NixOS/nixpkgs/nixpkgs-unstable";};
flake-utils = {url = "github:numtide/flake-utils";};
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
@ -15,15 +18,17 @@
flake-utils.follows = "flake-utils";
};
};
crane = {
url = "github:ipetkov/crane";
inputs = {
flake-utils.follows = "flake-utils";
flake-compat.follows = "flake-compat";
flake-utils.follows = "flake-utils";
nixpkgs.follows = "nixpkgs";
rust-overlay.follows = "rust-overlay";
};
};
advisory-db = {
url = "github:rustsec/advisory-db";
flake = false;
@ -48,34 +53,31 @@
rustStable =
pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
craneLib = (crane.mkLib pkgs).overrideToolchain rustStable;
src = ./.;
cargoArtifacts = craneLib.buildDepsOnly {inherit src buildInputs;};
buildInputs = [];
text-editor = craneLib.buildPackage {
inherit src;
doCheck = false;
};
text-editor-clippy = craneLib.cargoClippy {
inherit cargoArtifacts src buildInputs;
commonArgs = {
src = craneLib.cleanCargoSource ./.;
buildInputs = [];
nativeBuildInputs = [];
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
};
text-editor-fmt = craneLib.cargoFmt {inherit src;};
text-editor-audit = craneLib.cargoAudit {inherit src advisory-db;};
text-editor-nextest = craneLib.cargoNextest {
inherit cargoArtifacts src buildInputs;
partitions = 1;
partitionType = "count";
};
cargoArtifacts = craneLib.buildDepsOnly (commonArgs // {doCheck = false;});
text-editor = craneLib.buildPackage (commonArgs // {doCheck = false;});
text-editor-clippy = craneLib.cargoClippy (commonArgs
// {
inherit cargoArtifacts;
});
text-editor-fmt = craneLib.cargoFmt (commonArgs // {});
text-editor-audit = craneLib.cargoAudit (commonArgs // {inherit advisory-db;});
text-editor-nextest = craneLib.cargoNextest (commonArgs
// {
inherit cargoArtifacts;
src = ./.;
partitions = 1;
partitionType = "count";
});
in {
checks = {
inherit
text-editor
text-editor-audit
text-editor-clippy
text-editor-fmt
text-editor-nextest
;
inherit text-editor text-editor-audit text-editor-clippy text-editor-fmt text-editor-nextest;
};
packages.default = text-editor;
@ -90,6 +92,8 @@
cargo-release
rustStable
];
CARGO_REGISTRIES_CRATES_IO_PROTOCOL = "sparse";
};
});
}