23 lines
653 B
Nix
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
|
|
'';
|
|
};
|
|
}
|