refactor(flake): use flake-parts
This makes it easier to split up the flake in the future.
This commit is contained in:
parent
2a18f6bedb
commit
8242b83dd9
2 changed files with 83 additions and 70 deletions
126
flake.nix
126
flake.nix
|
@ -3,85 +3,77 @@
|
|||
inputs = {
|
||||
nixpkgs.url = "nixpkgs/nixos-unstable";
|
||||
systems.url = "github:nix-systems/default";
|
||||
flake-parts = {
|
||||
url = "github:hercules-ci/flake-parts";
|
||||
inputs.nixpkgs-lib.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
outputs =
|
||||
{
|
||||
self,
|
||||
nixpkgs,
|
||||
systems,
|
||||
}:
|
||||
let
|
||||
forEachSupportedSystem = nixpkgs.lib.genAttrs (import systems);
|
||||
in
|
||||
{
|
||||
checks = forEachSupportedSystem (
|
||||
system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
inherit (nixpkgs) lib;
|
||||
in
|
||||
inputs:
|
||||
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
|
||||
systems = import inputs.systems;
|
||||
perSystem =
|
||||
{
|
||||
fmtRust = pkgs.callPackage ./run-cmd.nix {
|
||||
src = self;
|
||||
name = "fmt-rust";
|
||||
extraNativeBuildInputs = [ pkgs.rustfmt ];
|
||||
cmd = "${lib.getExe pkgs.cargo} fmt --all --check --verbose";
|
||||
};
|
||||
fmtNix = pkgs.callPackage ./run-cmd.nix {
|
||||
src = self;
|
||||
name = "fmt-nix";
|
||||
cmd = "${lib.getExe self.formatter.${system}} --check .";
|
||||
};
|
||||
lintNix = pkgs.callPackage ./run-cmd.nix {
|
||||
src = self;
|
||||
name = "lint-nix";
|
||||
cmd = "${lib.getExe pkgs.statix} check .";
|
||||
};
|
||||
}
|
||||
);
|
||||
formatter = forEachSupportedSystem (system: nixpkgs.legacyPackages.${system}.nixfmt-rfc-style);
|
||||
|
||||
packages = forEachSupportedSystem (
|
||||
system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
webnsupdate = pkgs.callPackage ./default.nix { };
|
||||
in
|
||||
lib,
|
||||
pkgs,
|
||||
self',
|
||||
...
|
||||
}:
|
||||
{
|
||||
inherit webnsupdate;
|
||||
default = webnsupdate;
|
||||
cargo-update = pkgs.writeShellApplication {
|
||||
name = "cargo-update-lockfile";
|
||||
runtimeInputs = with pkgs; [
|
||||
cargo
|
||||
gnused
|
||||
];
|
||||
text = ''
|
||||
CARGO_TERM_COLOR=never cargo update 2>&1 | sed '/crates.io index/d' | tee -a cargo_update.log
|
||||
'';
|
||||
packages =
|
||||
let
|
||||
webnsupdate = pkgs.callPackage ./default.nix { };
|
||||
in
|
||||
{
|
||||
inherit webnsupdate;
|
||||
default = webnsupdate;
|
||||
cargo-update = pkgs.writeShellApplication {
|
||||
name = "cargo-update-lockfile";
|
||||
runtimeInputs = with pkgs; [
|
||||
cargo
|
||||
gnused
|
||||
];
|
||||
text = ''
|
||||
CARGO_TERM_COLOR=never cargo update 2>&1 | sed '/crates.io index/d' | tee -a cargo_update.log
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
formatter = pkgs.nixfmt-rfc-style;
|
||||
|
||||
checks = {
|
||||
fmtRust = pkgs.callPackage ./run-cmd.nix {
|
||||
src = inputs.self;
|
||||
name = "fmt-rust";
|
||||
extraNativeBuildInputs = [ pkgs.rustfmt ];
|
||||
cmd = "${lib.getExe pkgs.cargo} fmt --all --check --verbose";
|
||||
};
|
||||
fmtNix = pkgs.callPackage ./run-cmd.nix {
|
||||
src = inputs.self;
|
||||
name = "fmt-nix";
|
||||
cmd = "${lib.getExe self'.formatter} --check .";
|
||||
};
|
||||
lintNix = pkgs.callPackage ./run-cmd.nix {
|
||||
src = inputs.self;
|
||||
name = "lint-nix";
|
||||
cmd = "${lib.getExe pkgs.statix} check .";
|
||||
};
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
overlays.default = final: prev: { webnsupdate = final.callPackage ./default.nix { }; };
|
||||
|
||||
nixosModules.default = ./module.nix;
|
||||
|
||||
devShells = forEachSupportedSystem (
|
||||
system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
in
|
||||
{
|
||||
default = pkgs.mkShell {
|
||||
devShells.default = pkgs.mkShell {
|
||||
packages = [
|
||||
pkgs.cargo-insta
|
||||
pkgs.cargo-udeps
|
||||
pkgs.mold
|
||||
];
|
||||
};
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
flake = {
|
||||
overlays.default = final: prev: { webnsupdate = final.callPackage ./default.nix { }; };
|
||||
|
||||
nixosModules.default = ./module.nix;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue