nix: Add linting

This commit is contained in:
Tristan Daniël Maat 2024-01-02 15:06:58 +01:00
parent 40e0946201
commit 833f97c3d3
Signed by: tlater
GPG key ID: 49670FD774E43268
4 changed files with 30 additions and 3 deletions

View file

@ -74,7 +74,7 @@
}; };
checks.${system} = import ./nix/checks { checks.${system} = import ./nix/checks {
inherit self system pkgs; inherit self pkgs;
}; };
}; };
} }

View file

@ -1,9 +1,9 @@
{ {
pkgs, pkgs,
self, self,
system,
}: let }: let
callPackage = pkgs.lib.callPackageWith (pkgs // {inherit self;}); callPackage = pkgs.lib.callPackageWith (pkgs // {inherit self;});
in { in {
lintNix = callPackage ./lint-nix.nix {};
openHomepage = callPackage ./open-homepage.nix {}; openHomepage = callPackage ./open-homepage.nix {};
} }

27
nix/checks/lint-nix.nix Normal file
View file

@ -0,0 +1,27 @@
{
self,
lib,
stdenv,
alejandra,
deadnix,
statix,
}: let
inherit (lib) sourceFilesBySuffices;
in
stdenv.mkDerivation {
dontPatch = true;
dontConfigure = true;
dontBuild = true;
dontInstall = true;
doCheck = true;
name = "lint-nix";
src = sourceFilesBySuffices self [".nix"];
checkInputs = [alejandra deadnix statix];
checkPhase = ''
mkdir -p $out
alejandra --check . | tee $out/alejandra.log
deadnix --fail | tee $out/deadnix.log
statix check | tee $out/statix.log
'';
}

View file

@ -7,7 +7,7 @@
... ...
}: let }: let
inherit (lib) mkEnableOption mkIf mkOption; inherit (lib) mkEnableOption mkIf mkOption;
inherit (lib.types) submodule str int; inherit (lib.types) str int;
inherit (lib.strings) escapeShellArgs; inherit (lib.strings) escapeShellArgs;
inherit (self.packages.${system}) server templates; inherit (self.packages.${system}) server templates;