Files
nix/modules/git-hooks/default.nix
2026-02-05 16:04:00 +01:00

23 lines
653 B
Nix

{ config, lib, ... }:
{
options.services.git-hooks = {
enable = lib.mkEnableOption "Install git hooks for Nix flake";
flake-path = lib.mkOption {
type = lib.types.path;
description = "Path to Nix flake repository";
};
};
config = lib.mkIf config.services.git-hooks.enable {
system.activationScripts.git-hooks = lib.stringAfter [ "users" ] ''
if [ -d "${config.services.git-hooks.flake-path}/.git" ]; then
echo "🪝 Installing git hooks..."
cd ${config.services.git-hooks.flake-path}
nix run .#apps.x86_64-linux.pre-commit-install || true
echo " Done"
fi
'';
};
}