Fix: Simplify git hooks to just define in Nix, install with nix flake check
This commit is contained in:
@@ -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
|
||||||
|
|||||||
35
modules/git-hooks/default.nix
Normal file
35
modules/git-hooks/default.nix
Normal 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"
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user