about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2022-09-18 11:50:32 -0700
committerFranck Cuny <franck@fcuny.net>2022-09-18 11:50:32 -0700
commit03af560441c5f9d979dce33f67c6e5a39b6fdfe2 (patch)
tree709cdc1d479f85c58e2d1175ea628fd3987e7c63
parentref(flake): drop naersk for now (diff)
downloadworld-03af560441c5f9d979dce33f67c6e5a39b6fdfe2.tar.gz
ref(flake): move all the checks to external module
This improve the readability of the flake configuration, the check can
be in their own module.
-rw-r--r--flake.nix36
-rw-r--r--nix/checks.nix31
2 files changed, 34 insertions, 33 deletions
diff --git a/flake.nix b/flake.nix
index 1bb9b3d..125e214 100644
--- a/flake.nix
+++ b/flake.nix
@@ -43,7 +43,7 @@
   };
 
   # Output config, or config for NixOS system
-  outputs = { self, ... }@inputs:
+  outputs = { self, pre-commit-hooks, ... }@inputs:
     let
       inherit (inputs.futils.lib) eachSystem system;
       mySystems = [ system.x86_64-linux ];
@@ -65,37 +65,7 @@
             users.fcuny = import ./users/fcuny { inherit pkgs; };
           };
 
-          checks = {
-            pre-commit = inputs.pre-commit-hooks.lib.${system}.run {
-              src = ./.;
-
-              hooks = {
-                trailing-whitespace = {
-                  enable = true;
-                  entry =
-                    "${pkgs.python3Packages.pre-commit-hooks}/bin/trailing-whitespace-fixer";
-                  types = [ "text" ];
-                };
-
-                end-of-file-fixer = {
-                  enable = true;
-                  entry =
-                    "${pkgs.python3Packages.pre-commit-hooks}/bin/end-of-file-fixer";
-                  types = [ "text" ];
-                };
-
-                nixpkgs-fmt = { enable = true; };
-
-                terraform-format = { enable = true; };
-
-                shellcheck = {
-                  enable = true;
-                  files = "\\.sh$";
-                  types_or = [ "file" ];
-                };
-              };
-            };
-          };
+          checks = import ./nix/checks.nix { inherit pkgs pre-commit-hooks; };
 
           devShells = {
             default = pkgs.mkShell {
@@ -111,7 +81,7 @@
                 go
                 gopls
               ];
-              inherit (self.checks.${system}.pre-commit) shellHook;
+              inherit (self.checks.${system}.pre-commit-check) shellHook;
             };
           };
         }) // {
diff --git a/nix/checks.nix b/nix/checks.nix
new file mode 100644
index 0000000..aadb170
--- /dev/null
+++ b/nix/checks.nix
@@ -0,0 +1,31 @@
+{ pkgs, pre-commit-hooks, ... }:
+
+with pkgs;
+
+{
+  pre-commit-check = pre-commit-hooks.lib.${system}.run {
+    src = lib.cleanSource ../.;
+    hooks = {
+      nix-linter.enable = true;
+      nixpkgs-fmt.enable = true;
+      trailing-whitespace = {
+        enable = true;
+        entry =
+          "${pkgs.python3Packages.pre-commit-hooks}/bin/trailing-whitespace-fixer";
+        types = [ "text" ];
+      };
+      end-of-file-fixer = {
+        enable = true;
+        entry =
+          "${pkgs.python3Packages.pre-commit-hooks}/bin/end-of-file-fixer";
+        types = [ "text" ];
+      };
+      terraform-format = { enable = true; };
+      shellcheck = {
+        enable = true;
+        files = "\\.sh$";
+        types_or = [ "file" ];
+      };
+    };
+  };
+}