add flake checks and formatter, run some formatters
This commit is contained in:
parent
ce0e70f95a
commit
112654f448
4 changed files with 41 additions and 19 deletions
44
flake.nix
44
flake.nix
|
@ -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;
|
||||||
|
@ -21,13 +28,12 @@
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
||||||
craneLib = (crane.mkLib pkgs).overrideToolchain(_: toolchain);
|
craneLib = (crane.mkLib pkgs).overrideToolchain (_: toolchain);
|
||||||
lib = pkgs.lib;
|
lib = pkgs.lib;
|
||||||
|
|
||||||
# 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;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -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",
|
|
||||||
]
|
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue