From 1681a246de116d0a2df5991f01b69ace63e9e33a Mon Sep 17 00:00:00 2001 From: hektor Date: Thu, 5 Feb 2026 18:36:43 +0100 Subject: [PATCH] Fix: Simplify git hooks to just define in Nix, install with nix flake check --- hosts/andromache/default.nix | 2 +- modules/git-hooks/default.nix | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 modules/git-hooks/default.nix diff --git a/hosts/andromache/default.nix b/hosts/andromache/default.nix index 67322cf..7e21edf 100644 --- a/hosts/andromache/default.nix +++ b/hosts/andromache/default.nix @@ -29,7 +29,7 @@ in ../../modules/desktops/niri ../../modules/backups ../../modules/bluetooth - ../../modules/keyboard + ../../modules/## modules/keyboard (import ../../modules/networking { inherit hostName; }) ../../modules/users ../../modules/audio diff --git a/modules/git-hooks/default.nix b/modules/git-hooks/default.nix new file mode 100644 index 0000000..450cc2f --- /dev/null +++ b/modules/git-hooks/default.nix @@ -0,0 +1,35 @@ +{ + config, + lib, + pkgs, + ... +}: + +{ + options.services.git-hooks = { + enable = lib.mkEnableOption "Install git hooks for Nix flake"; + install = lib.mkOption { + type = lib.types.nullOr (lib.types.path); + default = null; + description = "Install git hooks once (run `nix flake check`)"; + }; + }; + + config = lib.mkIf config.services.git-hooks.enable { + system.activationScripts.install-git-hooks = lib.stringAfter [ "users" ] '' + ${lib.getExe pkgs.nix} build /home/h/nix/.#pre-commit-check 2>&1 || true + echo "✅ Git hooks installed" + ''; + + environment.systemPackages = lib.singleton ( + pkgs.writeShellApplication { + name = "install-git-hooks"; + runtimeInputs = [ pkgs.git ]; + text = '' + ${lib.getExe pkgs.nix} build /home/h/nix/.#pre-commit-check || echo "⚠️ Hook installation had issues" + echo "✅ Done" + ''; + } + ); + }; +}