summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorSilas Schöffel <sils@sils.li>2024-04-07 19:05:14 +0200
committerSilas Schöffel <sils@sils.li>2024-04-07 19:05:14 +0200
commitf836518bf06d80f58ca8fc3519010b1c46f042a5 (patch)
tree72be9b60b4c9c6c8ca1d8231aa945a136f5b61c5
parentflake: rename pre-commit-hooks-nix to git-hooks (diff)
downloadnix-config-f836518bf06d80f58ca8fc3519010b1c46f042a5.tar.gz
nix-config-f836518bf06d80f58ca8fc3519010b1c46f042a5.zip
treewide: enable pre-commit hooks
Diffstat (limited to '')
-rw-r--r--.gitignore1
-rw-r--r--flake.nix10
2 files changed, 11 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 6032f7a..59c86d6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
 .direnv
+.pre-commit-config.yaml
 hardware-configuration.nix
 result
diff --git a/flake.nix b/flake.nix
index d2cc2bf..f070713 100644
--- a/flake.nix
+++ b/flake.nix
@@ -174,6 +174,7 @@
     flake-utils,
     agenix,
     ragenix,
+    git-hooks,
     ...
   } @ attrs:
     flake-utils.lib.eachDefaultSystem (system: let
@@ -188,8 +189,11 @@
           plugins.airline.settings.theme = "minimalist";
         };
       nvim = nixvim.legacyPackages."${system}".makeNixvim nixVimConfig;
+      hooks = self.checks.${system}.pre-commit;
     in {
       devShells.default = pkgs.mkShell {
+        inherit (hooks) shellHook;
+        buildInputs = hooks.enabledPackages;
         packages = with pkgs; [
           nil
           statix
@@ -210,6 +214,12 @@
           inherit nvim;
           name = "My NixVim Configuration";
         };
+        pre-commit = git-hooks.lib.${system}.run {
+          src = ./.;
+          hooks = {
+            alejandra.enable = true;
+          };
+        };
       };
     })
     // {