nix: Add linting #27

Manually merged
tlater merged 1 commit from tlater/nix-linting into master 2024-01-02 15:33:57 +00:00
4 changed files with 30 additions and 3 deletions
Showing only changes of commit 833f97c3d3 - Show all commits

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;