{
description = "Home Manager file management tool";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
crane.url = "github:ipetkov/crane?ref=v0.21.3";
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{
self,
nixpkgs,
crane,
pre-commit-hooks,
}:
let
systems = [
"aarch64-linux"
"aarch64-darwin"
"x86_64-darwin"
"x86_64-linux"
];
forAllSystems =
f:
nixpkgs.lib.genAttrs systems (
system:
f rec {
inherit system;
pkgs = nixpkgs.legacyPackages.${system};
craneLib = crane.mkLib pkgs;
src = craneLib.cleanCargoSource ./.;
commonArgs = {
inherit src;
meta = with pkgs.lib; {
description = "Home Manager file management tool";
homepage = "https://sr.ht/~rycee/putter/";
license = licenses.eupl12; # Actually EUPL-1.2+
mainProgram = "putter";
platforms = platforms.unix;
};
};
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
crateCoverage = craneLib.cargoTarpaulin (
commonArgs
// {
inherit cargoArtifacts;
cargoTarpaulinExtraArgs = "--skip-clean --verbose --out html --output-dir $out";
}
);
crate = craneLib.buildPackage (commonArgs // { inherit cargoArtifacts; });
pre-commit-check = pre-commit-hooks.lib.${system}.run {
inherit src;
hooks = {
convco.enable = true;
nixfmt.enable = true;
rustfmt.enable = true;
};
};
}
);
in
{
packages = forAllSystems (p: {
default = p.crate;
inherit (p) cargoArtifacts crateCoverage;
});
checks = forAllSystems (p: {
inherit (p) crate pre-commit-check;
clippy =
with p;
craneLib.cargoClippy (
commonArgs
// {
inherit cargoArtifacts;
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
}
);
deny = with p; craneLib.cargoDeny commonArgs;
});
devShells = forAllSystems (p: {
default = p.craneLib.devShell {
checks = self.checks.${p.system};
packages = with p.pkgs; [
cargo-audit
cargo-deny
cargo-outdated
cargo-semver-checks
cargo-tarpaulin
git-cliff
(treefmt.withConfig {
runtimeInputs = [
deadnix
nixfmt
rustfmt
taplo
];
settings = pkgs.lib.importTOML ./treefmt.toml;
})
];
shellHook = p.pre-commit-check.shellHook;
};
});
};
}