Lots more updates
Also begin adding rust building capabilities to be able to write rust binaries for some commands.
This commit is contained in:
parent
624508dd14
commit
dd1cfa79e7
52 changed files with 2509 additions and 150 deletions
94
rust/default.nix
Normal file
94
rust/default.nix
Normal file
|
@ -0,0 +1,94 @@
|
|||
{
|
||||
pkgs,
|
||||
lib,
|
||||
crane,
|
||||
advisory-db,
|
||||
}:
|
||||
let
|
||||
rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
||||
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
|
||||
src = craneLib.cleanCargoSource ./.;
|
||||
commonArgs = {
|
||||
inherit src;
|
||||
strictDeps = true;
|
||||
buildInputs = [ ];
|
||||
};
|
||||
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
|
||||
individualCrateArgs = commonArgs // {
|
||||
inherit cargoArtifacts;
|
||||
inherit (craneLib.crateNameFromCargoToml { inherit src; }) version;
|
||||
doCheck = false;
|
||||
};
|
||||
fileSetForCrate =
|
||||
crate:
|
||||
lib.fileset.toSource {
|
||||
root = ./.;
|
||||
fileset = lib.fileset.unions [
|
||||
./Cargo.lock
|
||||
./Cargo.toml
|
||||
(craneLib.fileset.commonCargoSources ./lib/common)
|
||||
(craneLib.fileset.commonCargoSources ./program/${crate})
|
||||
];
|
||||
};
|
||||
in
|
||||
{
|
||||
buildRustPackage =
|
||||
crateName:
|
||||
craneLib.buildPackage (
|
||||
individualCrateArgs
|
||||
// {
|
||||
pname = crateName;
|
||||
cargoExtraArgs = "-p ${crateName}";
|
||||
src = fileSetForCrate crateName;
|
||||
}
|
||||
);
|
||||
checks = {
|
||||
rust-clippy = craneLib.cargoClippy (
|
||||
commonArgs
|
||||
// {
|
||||
inherit cargoArtifacts;
|
||||
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
|
||||
}
|
||||
);
|
||||
rust-doc = craneLib.cargoDoc (
|
||||
commonArgs
|
||||
// {
|
||||
inherit cargoArtifacts;
|
||||
}
|
||||
);
|
||||
rust-fmt = craneLib.cargoFmt (
|
||||
commonArgs
|
||||
// {
|
||||
inherit cargoArtifacts;
|
||||
}
|
||||
);
|
||||
# Not used currently, as I have some other formatter changing toml formatting
|
||||
# not sure where it comes from, but I need to find out and decide on a formatter
|
||||
rust-toml-fmt = craneLib.taploFmt {
|
||||
src = lib.sources.sourceFilesBySuffices src [ ".toml" ];
|
||||
};
|
||||
rust-audit = craneLib.cargoAudit {
|
||||
inherit src advisory-db;
|
||||
};
|
||||
rust-hakari = craneLib.mkCargoDerivation {
|
||||
inherit src;
|
||||
pname = "rust-hakari";
|
||||
cargoArtifacts = null;
|
||||
doInstallCargoArtifacts = false;
|
||||
|
||||
buildPhaseCargoCommand = ''
|
||||
cargo hakari generate --diff # workspace-hack Cargo.toml is up-to-date
|
||||
cargo hakari manage-deps --dry-run # all workspace crates depend on workspace-hack
|
||||
cargo hakari verify
|
||||
'';
|
||||
|
||||
nativeBuildInputs = [
|
||||
pkgs.cargo-hakari
|
||||
];
|
||||
};
|
||||
};
|
||||
devDeps = [
|
||||
pkgs.cargo-hakari
|
||||
rustToolchain
|
||||
];
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue