Make nix-collect-garbage -d look into more places

Make it look into the new-style profiles dir, the old-style one, and the
target of `~/.nix-profile` to be sure that we don't miss anything
This commit is contained in:
Théophane Hufschmitt 2023-04-03 15:13:11 +02:00
parent 81778c8d55
commit a57810b2ab

View file

@ -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) {