Files
nix/modules/git-hooks/default.nix

37 lines
860 B
Nix
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{
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"
'';
}
);
};
}