Fix: Simplify git hooks to just define in Nix, install with nix flake check
This commit is contained in:
35
modules/git-hooks/default.nix
Normal file
35
modules/git-hooks/default.nix
Normal file
@@ -0,0 +1,35 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
{
|
||||
options.services.git-hooks = {
|
||||
enable = lib.mkEnableOption "Install git hooks for Nix flake";
|
||||
install = lib.mkOption {
|
||||
type = lib.types.nullOr (lib.types.path);
|
||||
default = null;
|
||||
description = "Install git hooks once (run `nix flake check`)";
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf config.services.git-hooks.enable {
|
||||
system.activationScripts.install-git-hooks = lib.stringAfter [ "users" ] ''
|
||||
${lib.getExe pkgs.nix} build /home/h/nix/.#pre-commit-check 2>&1 || true
|
||||
echo "✅ Git hooks installed"
|
||||
'';
|
||||
|
||||
environment.systemPackages = lib.singleton (
|
||||
pkgs.writeShellApplication {
|
||||
name = "install-git-hooks";
|
||||
runtimeInputs = [ pkgs.git ];
|
||||
text = ''
|
||||
${lib.getExe pkgs.nix} build /home/h/nix/.#pre-commit-check || echo "⚠️ Hook installation had issues"
|
||||
echo "✅ Done"
|
||||
'';
|
||||
}
|
||||
);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user