37 lines
860 B
Nix
37 lines
860 B
Nix
{
|
||
config,
|
||
lib,
|
||
pkgs,
|
||
...
|
||
}:
|
||
|
||
{
|
||
options.services.git-hooks = {
|
||
enable = lib.mkEnableOption "Install git hooks for Nix flake";
|
||
};
|
||
|
||
config = lib.mkIf config.services.git-hooks.enable {
|
||
system.activationScripts.git-hooks = lib.stringAfter [ "users" ] ''
|
||
echo "🪝 Installing git hooks..."
|
||
cd /home/h/nix
|
||
|
||
# Use nix flake check which properly evaluates and installs hooks
|
||
nix flake check 2>&1 || true
|
||
'';
|
||
|
||
environment.systemPackages = lib.singleton (
|
||
pkgs.writeShellApplication {
|
||
name = "install-git-hooks";
|
||
runtimeInputs = [ pkgs.git ];
|
||
text = ''
|
||
set -euo pipefail
|
||
echo "🪝 Installing git hooks..."
|
||
cd /home/h/nix
|
||
nix flake check || echo "⚠️ Hook installation had issues"
|
||
echo "✅ Done"
|
||
'';
|
||
}
|
||
);
|
||
};
|
||
}
|