49 lines
1.1 KiB
Nix
49 lines
1.1 KiB
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
|
||
|
||
# Verify hooks were installed
|
||
if [ -f ".git/hooks/pre-commit" ]; then
|
||
echo "✅ Git hooks installed successfully"
|
||
else
|
||
echo "⚠️ Git hooks may not have installed properly"
|
||
fi
|
||
'';
|
||
|
||
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"
|
||
'';
|
||
}
|
||
);
|
||
};
|
||
}
|
||
|
||
);
|
||
};
|
||
}
|