refactor(flake.nix): Use flake-parts to simplify flake.nix
This commit is contained in:
parent
f7a64063bb
commit
e75c7b831b
10 changed files with 381 additions and 271 deletions
|
|
@ -1,47 +1,83 @@
|
|||
{ flake-inputs }:
|
||||
let
|
||||
inherit (flake-inputs.nixpkgs) lib;
|
||||
pkgs = flake-inputs.nixpkgs.legacyPackages.x86_64-linux;
|
||||
checkLib = pkgs.callPackage ./lib.nix { };
|
||||
in
|
||||
{ self, ... }:
|
||||
{
|
||||
x86_64-linux = lib.mergeAttrsList [
|
||||
flake-inputs.self.nixosConfigurations.hetzner-1.config.serviceTests
|
||||
|
||||
perSystem =
|
||||
{
|
||||
nix = checkLib.mkLint {
|
||||
name = "nix-lints";
|
||||
fileset = lib.fileset.fileFilter (file: file.hasExt "nix") ../.;
|
||||
inputs',
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
{
|
||||
checks =
|
||||
let
|
||||
mkLint =
|
||||
{
|
||||
name,
|
||||
fileset,
|
||||
checkInputs ? [ ],
|
||||
script,
|
||||
}:
|
||||
pkgs.stdenvNoCC.mkDerivation {
|
||||
inherit name;
|
||||
|
||||
checkInputs = lib.attrValues {
|
||||
inherit (pkgs) deadnix nixfmt-rfc-style;
|
||||
src = lib.fileset.toSource {
|
||||
root = ../.;
|
||||
fileset = lib.fileset.difference fileset (
|
||||
lib.fileset.fileFilter (
|
||||
file: file.type != "regular" || file.name == "hardware-configuration.nix"
|
||||
) ../.
|
||||
);
|
||||
};
|
||||
|
||||
statix = pkgs.statix.overrideAttrs (old: {
|
||||
patches = old.patches ++ [
|
||||
(pkgs.fetchpatch {
|
||||
url = "https://github.com/oppiliappan/statix/commit/925dec39bb705acbbe77178b4d658fe1b752abbb.patch";
|
||||
hash = "sha256-0wacO6wuYJ4ufN9PGucRVJucFdFFNF+NoHYIrLXsCWs=";
|
||||
})
|
||||
];
|
||||
});
|
||||
};
|
||||
checkInputs = [ pkgs.nushell ] ++ checkInputs;
|
||||
|
||||
script = ''
|
||||
statix check **/*.nix
|
||||
deadnix --fail **/*.nix
|
||||
nixfmt --check --strict **/*.nix
|
||||
'';
|
||||
};
|
||||
checkPhase = ''
|
||||
nu -c '${script}' | tee $out
|
||||
'';
|
||||
|
||||
lockfile = checkLib.mkLint {
|
||||
name = "nix-lockfile";
|
||||
fileset = ../flake.lock;
|
||||
checkInputs = lib.attrValues { inherit (flake-inputs.flint.packages.x86_64-linux) flint; };
|
||||
dontPatch = true;
|
||||
dontConfigure = true;
|
||||
dontBuild = true;
|
||||
dontInstall = true;
|
||||
dontFixup = true;
|
||||
doCheck = true;
|
||||
};
|
||||
in
|
||||
{
|
||||
nix = mkLint {
|
||||
name = "nix-lints";
|
||||
fileset = lib.fileset.fileFilter (file: file.hasExt "nix") ../.;
|
||||
|
||||
script = ''
|
||||
flint --fail-if-multiple-versions
|
||||
'';
|
||||
};
|
||||
}
|
||||
];
|
||||
checkInputs = lib.attrValues {
|
||||
inherit (pkgs) deadnix nixfmt-rfc-style;
|
||||
|
||||
statix = pkgs.statix.overrideAttrs (old: {
|
||||
patches = old.patches ++ [
|
||||
(pkgs.fetchpatch {
|
||||
url = "https://github.com/oppiliappan/statix/commit/925dec39bb705acbbe77178b4d658fe1b752abbb.patch";
|
||||
hash = "sha256-0wacO6wuYJ4ufN9PGucRVJucFdFFNF+NoHYIrLXsCWs=";
|
||||
})
|
||||
];
|
||||
});
|
||||
};
|
||||
|
||||
script = /* bash */ ''
|
||||
statix check **/*.nix
|
||||
deadnix --fail **/*.nix
|
||||
nixfmt --check --strict **/*.nix
|
||||
'';
|
||||
};
|
||||
|
||||
lockfile = mkLint {
|
||||
name = "nix-lockfile";
|
||||
fileset = ../flake.lock;
|
||||
checkInputs = lib.attrValues { inherit (inputs'.flint.packages) flint; };
|
||||
|
||||
script = /* bash */ ''
|
||||
flint --fail-if-multiple-versions
|
||||
'';
|
||||
};
|
||||
}
|
||||
// self.nixosConfigurations.hetzner-1.config.serviceTests;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,35 +0,0 @@
|
|||
{ pkgs, lib, ... }:
|
||||
{
|
||||
mkLint =
|
||||
{
|
||||
name,
|
||||
fileset,
|
||||
checkInputs ? [ ],
|
||||
script,
|
||||
}:
|
||||
pkgs.stdenvNoCC.mkDerivation {
|
||||
inherit name;
|
||||
|
||||
src = lib.fileset.toSource {
|
||||
root = ../.;
|
||||
fileset = lib.fileset.difference fileset (
|
||||
lib.fileset.fileFilter (
|
||||
file: file.type != "regular" || file.name == "hardware-configuration.nix"
|
||||
) ../.
|
||||
);
|
||||
};
|
||||
|
||||
checkInputs = [ pkgs.nushell ] ++ checkInputs;
|
||||
|
||||
checkPhase = ''
|
||||
nu -c '${script}' | tee $out
|
||||
'';
|
||||
|
||||
dontPatch = true;
|
||||
dontConfigure = true;
|
||||
dontBuild = true;
|
||||
dontInstall = true;
|
||||
dontFixup = true;
|
||||
doCheck = true;
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue