add flake checks and formatter, run some formatters

This commit is contained in:
cy 2025-05-11 00:32:41 -04:00
parent ce0e70f95a
commit 112654f448
4 changed files with 41 additions and 19 deletions

View file

@ -11,8 +11,15 @@
}; };
}; };
outputs = inputs@{ nixpkgs, flake-utils, crane, ... }: outputs =
flake-utils.lib.eachDefaultSystem (system: inputs@{
nixpkgs,
flake-utils,
crane,
...
}:
flake-utils.lib.eachDefaultSystem (
system:
let let
pkgs = import nixpkgs { pkgs = import nixpkgs {
inherit system; inherit system;
@ -26,8 +33,7 @@
# don't clean cpp files # don't clean cpp files
cppFilter = path: _type: builtins.match ".*(cpp|hpp)$" path != null; cppFilter = path: _type: builtins.match ".*(cpp|hpp)$" path != null;
cppOrCargo = path: type: cppOrCargo = path: type: (cppFilter path type) || (craneLib.filterCargoSources path type);
(cppFilter path type) || (craneLib.filterCargoSources path type);
src = lib.cleanSourceWith { src = lib.cleanSourceWith {
src = ./.; src = ./.;
filter = cppOrCargo; filter = cppOrCargo;
@ -53,11 +59,33 @@
}; };
cargoArtifacts = craneLib.buildDepsOnly commonArgs; cargoArtifacts = craneLib.buildDepsOnly commonArgs;
nixcp = craneLib.buildPackage (commonArgs // { nixcp = craneLib.buildPackage (
commonArgs
// {
inherit cargoArtifacts; inherit cargoArtifacts;
}); }
);
in in
{ {
checks = {
# clippy with all warnings denied
clippy = craneLib.cargoClippy (
commonArgs
// {
inherit cargoArtifacts;
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
}
);
# check formatting
cargoFmt = craneLib.cargoFmt {
inherit src;
};
tomlFmt = craneLib.taploFmt {
src = lib.sources.sourceFilesBySuffices src [ ".toml" ];
};
};
devShells.default = craneLib.devShell { devShells.default = craneLib.devShell {
inputsFrom = [ nixcp ]; inputsFrom = [ nixcp ];
@ -71,6 +99,8 @@
]; ];
}; };
formatter = pkgs.nixfmt-rfc-style;
packages.default = nixcp; packages.default = nixcp;
} }
); );

View file

@ -1,9 +1,4 @@
[toolchain] [toolchain]
channel = "nightly" channel = "nightly"
profile = "minimal" profile = "minimal"
components = [ components = ["rust-src", "rust-analyzer", "rustfmt", "clippy"]
"rust-src",
"rust-analyzer",
"rustfmt",
"clippy",
]

View file

@ -1,2 +0,0 @@

View file

@ -3,7 +3,6 @@ use std::path::PathBuf;
use clap::{Args, Parser, Subcommand}; use clap::{Args, Parser, Subcommand};
mod bindings; mod bindings;
mod cli;
pub mod make_nar; pub mod make_nar;
pub mod path_info; pub mod path_info;
pub mod push; pub mod push;