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

home-manager: handle missing per-user profiles directory #3742

Merged
merged 2 commits into from
Mar 8, 2023

Conversation

rycee
Copy link
Member

@rycee rycee commented Mar 5, 2023

Description

Specifically, if the global per-user profiles path do not exist and we cannot create it during the activation, then place our profile in the Home Manager data directory. We prefer to use the global location, though, since it makes it visible to nix-collect-garbage.

This is intended to improve compatibility with Nix version 2.14 and later, which no longer creates the per-user directories.

Also, use the Home Manager data directory to manage the gcroot for the current generation. It does not have to sit in the global per-user gcroots directory since it should never be eligible for GC.

Checklist

  • Change is backwards compatible. Assuming no reliance on location of gcroot and profile.

  • Code formatted with ./format.

  • Code tested through nix-shell --pure tests -A run.all.

  • Test cases updated/added. See example.

  • Commit messages are formatted like

    {component}: {description}
    
    {long description}
    

@rycee rycee self-assigned this Mar 5, 2023
@ncfavier
Copy link
Member

ncfavier commented Mar 5, 2023

Note there are still references to the per-user profile dir in home-manager/home-manager, not sure if that's intentional.

@rycee
Copy link
Member Author

rycee commented Mar 6, 2023

Unfortunately, I didn't have time to finish the changes but figured I'd create this draft PR to show that there is some action on the issue. Turns out we'll need to support both profile locations for the time being since we need to maintain some backwards compatibility.

Specifically, if the global per-user profiles path do not exist and we
cannot create it during the activation, then place our profile in the
Home Manager data directory. We prefer to use the global location,
though, since it makes it visible to `nix-collect-garbage`.

This is intended to improve compatibility with Nix version 2.14 and
later, which no longer creates the per-user directories.

Also, use the Home Manager data directory to manage the gcroot for the
current generation. It does not have to sit in the global per-user
gcroots directory since it should never be eligible for GC.
@rycee rycee force-pushed the migrate-profiles-and-gcroot branch from 08f7821 to f698164 Compare March 7, 2023 22:53
@rycee rycee merged commit f698164 into master Mar 8, 2023
@rycee rycee deleted the migrate-profiles-and-gcroot branch March 8, 2023 09:05
@jisantuc
Copy link

jisantuc commented Mar 8, 2023

Thanks for the fast fix here ❤️

@Ericson2314
Copy link
Contributor

N.B. you will want to use ${XDG_STATE_HOME-$HOME/.local/state/nix not .../home-manager for nix-collect-garbage to work.`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants