Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nix-collect-garbage -d with the new profile location #7993

Merged
merged 1 commit into from
Mar 8, 2023

Conversation

thufschmitt
Copy link
Member

Low-hanging fix for #5226 (comment)

Checklist for maintainers

Maintainers: tick if completed or explain if not relevant

  • agreed on idea
  • agreed on implementation strategy
  • tests, as appropriate
    • functional tests - tests/**.sh
    • unit tests - src/*/tests
    • integration tests - tests/nixos/*
  • documentation in the manual
  • code and comments are self-explanatory
  • commit message explains why the change was made
  • new feature or incompatible change: updated release notes

Priorities

Add 👍 to pull requests you find important.

@Ericson2314 Ericson2314 added the backport 2.14-maintenance Automatically creates a PR against the branch label Mar 7, 2023
Copy link
Member

@Ericson2314 Ericson2314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, and I assume we'll want the backport too?

@github-actions
Copy link

github-actions bot commented Mar 8, 2023

Successfully created backport PR for 2.14-maintenance:

@rycee
Copy link
Member

rycee commented Mar 8, 2023

I think it may be worth keeping removal of old generations also for profiles in the old Nix state directory, if it exists. Otherwise, this changed behavior could cause unexpected accumulation of garbage for people who use custom profiles in the per-user directory. And the documentation for nix-collect-garbage still specifically say that it will look in the old directory:

However, it provides two additional options: -d (--delete-old), which deletes all old generations of all profiles in /nix/var/nix/profiles by invoking nix-env --delete-generations old on all profiles (of course, this makes rollbacks to previous configurations impossible); and --delete-older-than period, where period is a value such as 30d, which deletes all generations older than the specified number of days in all profiles in /nix/var/nix/profiles (except for the generations that were active at that point in time).

@Ericson2314
Copy link
Member

@rycee See tests/user-envs-migration.sh. I have misunderstood the intent before, and do not yet understand how it actually works, but the intent seems to be to migrate by movi9ng everything to the new directory so it can be garbage collected there.

I agreed these references to the old directory should be cleaned up, however.

@thufschmitt thufschmitt mentioned this pull request Mar 9, 2023
7 tasks
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2023-03-10-nix-team-meeting-minutes-39/26279/1

thufschmitt pushed a commit to tweag/nix that referenced this pull request Aug 1, 2023
Fix `nix-collect-garbage -d` with the new profile location
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.14-maintenance Automatically creates a PR against the branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants