Skip to content

Commit

Permalink
feat: add an option to disable gc root creation
Browse files Browse the repository at this point in the history
Mostly for testing.
  • Loading branch information
sandydoo committed Aug 24, 2024
1 parent 6736cfd commit 949d02b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion modules/pre-commit.nix
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,14 @@ in
internal = true;
};

addGcRoot = mkOption {
type = types.bool;
default = true;
description = ''
Whether to add the generated pre-commit-config.json to the garbage collector roots.
'';
};

assertions = lib.mkOption {
type = types.listOf types.unspecified;
internal = true;
Expand Down Expand Up @@ -351,7 +359,11 @@ in
echo 1>&2 " 2. remove .pre-commit-config.yaml"
echo 1>&2 " 3. add .pre-commit-config.yaml to .gitignore"
else
nix-store --add-root "''${GIT_WC}/.pre-commit-config.yaml" --realise ${configFile}
if [ $]
nix-store --add-root "''${GIT_WC}/.pre-commit-config.yaml" --realise ${configFile}
else
ln -fs ${configFile} "''${GIT_WC}/.pre-commit-config.yaml"
fi
# Remove any previously installed hooks (since pre-commit itself has no convergent design)
hooks="${concatStringsSep " " (remove "manual" supportedHooksLib.supportedHooks )}"
for hook in $hooks; do
Expand Down
2 changes: 1 addition & 1 deletion nix/installation-test.nix
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ let

executeTest = lib.mapAttrsToList
(name: test:
let runDerivation = run ({ src = null; } // test.conf);
let runDerivation = run ({ src = null; addGcRoot = false; } // test.conf);
in ''
rm -f ~/.git/hooks/*
${runDerivation.shellHook}
Expand Down

0 comments on commit 949d02b

Please sign in to comment.