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

36 lines
934 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";
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"
'';
}
);
};
}