mirror of
https://github.com/NixOS/nix
synced 2025-07-07 22:33:57 +02:00
Merge pull request #8350 from NixOS/backport-8154-to-2.15-maintenance
[Backport 2.15-maintenance] Make `nix-collect-garbage -d` look into more places
This commit is contained in:
commit
9204ab4d58
2 changed files with 20 additions and 4 deletions
|
@ -77,7 +77,12 @@ static int main_nix_collect_garbage(int argc, char * * argv)
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (removeOld) removeOldGenerations(profilesDir());
|
if (removeOld) {
|
||||||
|
std::set<Path> dirsToClean = {
|
||||||
|
profilesDir(), settings.nixStateDir + "/profiles", dirOf(getDefaultProfile())};
|
||||||
|
for (auto & dir : dirsToClean)
|
||||||
|
removeOldGenerations(dir);
|
||||||
|
}
|
||||||
|
|
||||||
// Run the actual garbage collector.
|
// Run the actual garbage collector.
|
||||||
if (!dryRun) {
|
if (!dryRun) {
|
||||||
|
|
17
tests/gc.sh
17
tests/gc.sh
|
@ -52,9 +52,7 @@ rmdir $NIX_STORE_DIR/.links
|
||||||
rmdir $NIX_STORE_DIR
|
rmdir $NIX_STORE_DIR
|
||||||
|
|
||||||
## Test `nix-collect-garbage -d`
|
## Test `nix-collect-garbage -d`
|
||||||
# `nix-env` doesn't work with CA derivations, so let's ignore that bit if we're
|
testCollectGarbageD () {
|
||||||
# using them
|
|
||||||
if [[ -z "${NIX_TESTS_CA_BY_DEFAULT:-}" ]]; then
|
|
||||||
clearProfiles
|
clearProfiles
|
||||||
# Run two `nix-env` commands, should create two generations of
|
# Run two `nix-env` commands, should create two generations of
|
||||||
# the profile
|
# the profile
|
||||||
|
@ -66,4 +64,17 @@ if [[ -z "${NIX_TESTS_CA_BY_DEFAULT:-}" ]]; then
|
||||||
# left
|
# left
|
||||||
nix-collect-garbage -d
|
nix-collect-garbage -d
|
||||||
[[ $(nix-env --list-generations | wc -l) -eq 1 ]]
|
[[ $(nix-env --list-generations | wc -l) -eq 1 ]]
|
||||||
|
}
|
||||||
|
# `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
|
||||||
|
testCollectGarbageD
|
||||||
|
|
||||||
|
# Run the same test, but forcing the profiles at their legacy location under
|
||||||
|
# /nix/var/nix.
|
||||||
|
#
|
||||||
|
# Regression test for #8294
|
||||||
|
rm ~/.nix-profile
|
||||||
|
ln -s $NIX_STATE_DIR/profiles/per-user/me ~/.nix-profile
|
||||||
|
testCollectGarbageD
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue