{
description = "Home Manager file management tool";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
crane.url = "github:ipetkov/crane?ref=v0.20.3";
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{
self,
nixpkgs,
flake-utils,
crane,
pre-commit-hooks,
}:
let
systems = [
"aarch64-linux"
"aarch64-darwin"
"x86_64-darwin"
"x86_64-linux"
];
in
flake-utils.lib.eachSystem systems (
system:
let
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.gpl3Plus;
mainProgram = "putter";
platforms = platforms.unix;
};
};
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
crateClippy = craneLib.cargoClippy (commonArgs // { inherit cargoArtifacts; });
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-rfc-style.enable = true;
rustfmt.enable = true;
};
};
in
{
packages = {
default = crate;
inherit cargoArtifacts crateCoverage;
};
apps.default = flake-utils.lib.mkApp { drv = crate; };
checks = {
inherit
crate
crateClippy
crateCoverage
pre-commit-check
;
};
devShells.default = craneLib.devShell {
checks = self.checks.${system};
packages = with pkgs; [
cargo-audit
cargo-outdated
];
shellHook = pre-commit-check.shellHook;
};
}
);
}