Merge pull request #7993 from tweag/fix-profile-gc
Fix `nix-collect-garbage -d` with the new profile location
This commit is contained in:
commit
6b243ef2d5
2 changed files with 18 additions and 2 deletions
|
@ -77,8 +77,7 @@ static int main_nix_collect_garbage(int argc, char * * argv)
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
auto profilesDir = settings.nixStateDir + "/profiles";
|
if (removeOld) removeOldGenerations(profilesDir());
|
||||||
if (removeOld) removeOldGenerations(profilesDir);
|
|
||||||
|
|
||||||
// Run the actual garbage collector.
|
// Run the actual garbage collector.
|
||||||
if (!dryRun) {
|
if (!dryRun) {
|
||||||
|
|
17
tests/gc.sh
17
tests/gc.sh
|
@ -50,3 +50,20 @@ if test -e $outPath/foobar; then false; fi
|
||||||
# Check that the store is empty.
|
# Check that the store is empty.
|
||||||
rmdir $NIX_STORE_DIR/.links
|
rmdir $NIX_STORE_DIR/.links
|
||||||
rmdir $NIX_STORE_DIR
|
rmdir $NIX_STORE_DIR
|
||||||
|
|
||||||
|
## Test `nix-collect-garbage -d`
|
||||||
|
# `nix-env` doesn't work with CA derivations, so let's ignore that bit if we're
|
||||||
|
# using them
|
||||||
|
if [[ -z "${NIX_TESTS_CA_BY_DEFAULT:-}" ]]; then
|
||||||
|
clearProfiles
|
||||||
|
# Run two `nix-env` commands, should create two generations of
|
||||||
|
# the profile
|
||||||
|
nix-env -f ./user-envs.nix -i foo-1.0
|
||||||
|
nix-env -f ./user-envs.nix -i foo-2.0pre1
|
||||||
|
[[ $(nix-env --list-generations | wc -l) -eq 2 ]]
|
||||||
|
|
||||||
|
# Clear the profile history. There should be only one generation
|
||||||
|
# left
|
||||||
|
nix-collect-garbage -d
|
||||||
|
[[ $(nix-env --list-generations | wc -l) -eq 1 ]]
|
||||||
|
fi
|
||||||
|
|
Loading…
Reference in a new issue