My nix-darwin and NixOS config
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: conditional hook creation

+7 -2
+7 -2
modules/common.nix
··· 27 27 # Symlink tracked hooks into .git/hooks so they're always up to date. 28 28 system.activationScripts.installGitHooks = '' 29 29 REPO="/home/${cfg.user.username}/.config/nix-config" 30 + HOOK="$REPO/.git/hooks/pre-commit" 31 + TARGET="$REPO/hooks/pre-commit" 30 32 if [ -d "$REPO/.git" ]; then 31 - ln -sf "$REPO/hooks/pre-commit" "$REPO/.git/hooks/pre-commit" 32 - chmod +x "$REPO/hooks/pre-commit" 33 + # Only (re)create the symlink if it's missing or points somewhere else. 34 + if [ "$(readlink "$HOOK" 2>/dev/null)" != "$TARGET" ]; then 35 + ln -sf "$TARGET" "$HOOK" 36 + chmod +x "$TARGET" 37 + fi 33 38 fi 34 39 ''; 35 40