From 833f97c3d3c1cb5472d654ca42b157dc0ae63ffb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tristan=20Dani=C3=ABl=20Maat?= Date: Tue, 2 Jan 2024 15:06:58 +0100 Subject: [PATCH] nix: Add linting --- flake.nix | 2 +- nix/checks/default.nix | 2 +- nix/checks/lint-nix.nix | 27 +++++++++++++++++++++++++++ nix/module.nix | 2 +- 4 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 nix/checks/lint-nix.nix diff --git a/flake.nix b/flake.nix index bc7a49a..353fa71 100644 --- a/flake.nix +++ b/flake.nix @@ -74,7 +74,7 @@ }; checks.${system} = import ./nix/checks { - inherit self system pkgs; + inherit self pkgs; }; }; } diff --git a/nix/checks/default.nix b/nix/checks/default.nix index fa4be77..1d24e35 100644 --- a/nix/checks/default.nix +++ b/nix/checks/default.nix @@ -1,9 +1,9 @@ { pkgs, self, - system, }: let callPackage = pkgs.lib.callPackageWith (pkgs // {inherit self;}); in { + lintNix = callPackage ./lint-nix.nix {}; openHomepage = callPackage ./open-homepage.nix {}; } diff --git a/nix/checks/lint-nix.nix b/nix/checks/lint-nix.nix new file mode 100644 index 0000000..aed1fb1 --- /dev/null +++ b/nix/checks/lint-nix.nix @@ -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 + ''; + } diff --git a/nix/module.nix b/nix/module.nix index 6515c54..b2279e1 100644 --- a/nix/module.nix +++ b/nix/module.nix @@ -7,7 +7,7 @@ ... }: let inherit (lib) mkEnableOption mkIf mkOption; - inherit (lib.types) submodule str int; + inherit (lib.types) str int; inherit (lib.strings) escapeShellArgs; inherit (self.packages.${system}) server templates;