{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
advisory-db = {
url = "github:rustsec/advisory-db";
flake = false;
};
};
outputs = { self, nixpkgs, crane, flake-utils, advisory-db, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
};
inherit (pkgs) lib;
craneLib = crane.lib.${system};
src = craneLib.cleanCargoSource ./.;
buildInputs = [
] ++ lib.optionals pkgs.stdenv.isDarwin [
pkgs.libiconv
];
cargoArtifacts = craneLib.buildDepsOnly {
inherit src buildInputs;
};
titanircd = craneLib.buildPackage {
inherit cargoArtifacts src buildInputs;
};
in
{
checks = {
inherit titanircd;
titanircd-clippy = craneLib.cargoClippy {
inherit cargoArtifacts src buildInputs;
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
};
titanircd-doc = craneLib.cargoDoc {
inherit cargoArtifacts src buildInputs;
};
titanircd-fmt = craneLib.cargoFmt {
inherit src;
};
titanircd-audit = craneLib.cargoAudit {
inherit src advisory-db;
};
titanircd-nextest = craneLib.cargoNextest {
inherit cargoArtifacts src buildInputs;
partitions = 1;
partitionType = "count";
};
} // lib.optionalAttrs (system == "x86_64-linux") {
titanircd-coverage = craneLib.cargoTarpaulin {
inherit cargoArtifacts src;
};
};
packages.default = titanircd;
apps.default = flake-utils.lib.mkApp {
drv = titanircd;
};
devShells.default = pkgs.mkShell {
inputsFrom = builtins.attrValues self.checks;
nativeBuildInputs = with pkgs; [
cargo
rustc
];
};
});
}