git-hooks.nix icon indicating copy to clipboard operation
git-hooks.nix copied to clipboard

create a custom pre-commit install command which ensures the store paths used land in a derivation and are protected from gc

Open RonnyPfannschmidt opened this issue 3 years ago • 6 comments

RonnyPfannschmidt avatar Sep 09 '22 08:09 RonnyPfannschmidt

The .pre-commit-config.yaml symlink produced by the shellHook script is already a GC root. Does it not work for you? EDIT: WRONG

roberth avatar Sep 09 '22 08:09 roberth

@roberth then i missed a detail - as per #160 i'd like to use a out of the checkout conifg file

if the in checkout file is also being used as gc root, then its a slightly different handling

RonnyPfannschmidt avatar Sep 09 '22 09:09 RonnyPfannschmidt

@roberth i just hada nix gc destroy my pre-commit hook as installed, is there a way to fix that ?

RonnyPfannschmidt avatar Sep 27 '22 08:09 RonnyPfannschmidt

@roberth what i observe is that practically every nix gc call wll destroy the pre commit hooks, including the config files

what can be done to sort that out?

RonnyPfannschmidt avatar Oct 06 '22 09:10 RonnyPfannschmidt

I wrongly assumed the symlink was a gc root. I didn't find a good solution for creating one. See https://github.com/NixOS/nix/issues/7138

roberth avatar Oct 06 '22 09:10 roberth

Mine don't get GC-ed because lorri creates gc roots for the shells that reference them. Lorri shouldn't be a requirement though.

roberth avatar Oct 06 '22 15:10 roberth