Merge remote-tracking branch 'tweag/delete-old-on-all-profiles-dir'

Pre-merge of https://github.com/NixOS/nix/pull/8154
This commit is contained in:
Max Headroom 2023-05-14 16:57:33 +02:00
commit d9e7c9777c
2 changed files with 7 additions and 2 deletions

View file

@ -92,7 +92,7 @@ poly_configure_nix_daemon_service() {
task "Setting up the nix-daemon systemd service" task "Setting up the nix-daemon systemd service"
_sudo "to create the nix-daemon tmpfiles config" \ _sudo "to create the nix-daemon tmpfiles config" \
ln -sfn /nix/var/nix/profiles/default/$TMPFILES_SRC $TMPFILES_DEST ln -sfn "/nix/var/nix/profiles/default$TMPFILES_SRC" "$TMPFILES_DEST"
_sudo "to run systemd-tmpfiles once to pick that path up" \ _sudo "to run systemd-tmpfiles once to pick that path up" \
systemd-tmpfiles --create --prefix=/nix/var/nix systemd-tmpfiles --create --prefix=/nix/var/nix

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