Fix: Simplify git hooks to just define in Nix, install with nix flake check

This commit is contained in:
2026-02-05 18:36:43 +01:00
parent 0d860d4a4f
commit 1681a246de
2 changed files with 36 additions and 1 deletions

View File

@@ -29,7 +29,7 @@ in
../../modules/desktops/niri ../../modules/desktops/niri
../../modules/backups ../../modules/backups
../../modules/bluetooth ../../modules/bluetooth
../../modules/keyboard ../../modules/## modules/keyboard
(import ../../modules/networking { inherit hostName; }) (import ../../modules/networking { inherit hostName; })
../../modules/users ../../modules/users
../../modules/audio ../../modules/audio

View File

@@ -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"
'';
}
);
};
}