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

New profile location breaks home-manager #7930

Closed
ncfavier opened this issue Mar 1, 2023 · 8 comments
Closed

New profile location breaks home-manager #7930

ncfavier opened this issue Mar 1, 2023 · 8 comments
Labels
bug profiles Versioned gc root symlinks; nix profile, nix-env

Comments

@ncfavier
Copy link
Member

ncfavier commented Mar 1, 2023

Describe the bug

Nix 2.14 (presumably #5226) breaks the home-manager tests: https://github.com/nix-community/home-manager/actions/runs/4301868239/jobs/7499628919#step:8:260

(We're pinned on 2.13 for now, so no emergency)

The relevant code where home-manager seems to assume things about the default profile location is https://github.com/nix-community/home-manager/blob/master/modules/lib-bash/activation-init.sh

Does home-manager need to change, and if so, would those changes be compatible with older versions of Nix?

(I've spent exactly 0 seconds thinking about this, I'm just reporting the problem. 😴)

cc @fricklerhandwerk

Priorities

Add 👍 to issues you find important.

@thufschmitt
Copy link
Member

Thanks for opening that.

Also see nix-community/home-manager#2544 (which offers what I think is the best solution to that on the HM side) and NixOS/nixpkgs#218858 .

I'm also working on a patch to provide some best-effort backwards-compatibility, but it's probably not going to be 100% reliable if people decide to tweak things a bit

@fricklerhandwerk
Copy link
Contributor

Discussed in the Nix team meeting 2023-03-23:

  • @Ericson2314: Backwards compat seems too painful.

    • @rycee said he doesn't mind the breakage as long as there is clear direction. I think we can provide it, and by deduplicatin the code (as @thufschmitt has been doing), we can be confident in our guidance.
  • No disagreement

  • @eriscon2314: On the other hand, I worry making the XDG stuff behind a flag will not be clear enough direction

    • this is probably a different conversation
  • Discussion on how to adapt nix-collect-garabage -d:

    • decision:
      • Before: Look at all users in /nix/var/nix and garbage-collect profiles
      • After: Look at just the current user in new $XDG_STATE_HOME, but not other users' profiles
    • Look at ~/.nix-profile? Not sure
    • With the new location, trawling through users' home directories seems wrong
    • A sysadmin that needs to e.g. forcably reclaim space could still su each user in a loop to delete old profiles.
  • @rycee based on the above, if you want nix-collect-garbage -d to collect the current user's Home Manager generations, you should put them into ${XDG_STATE_HOME-$HOME/.local/state}/nix/profiles.

@nixos-discourse
Copy link

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

https://discourse.nixos.org/t/2023-03-23-nix-team-meeting-minutes-43/26758/1

@roberth roberth added the profiles Versioned gc root symlinks; nix profile, nix-env label Mar 31, 2023
@thufschmitt
Copy link
Member

Closing since home-manager isn't impacted by this any more

@nixos-discourse
Copy link

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

https://discourse.nixos.org/t/2023-03-31-nix-team-meeting-minutes-45/27002/1

@flokli
Copy link
Contributor

flokli commented Sep 2, 2023

My home-manager still/again seems to be impacted, ran into this when trying to start the home-manager-flokli.service on a new NixOS box.

What's the recommended way forward here? Should I just mkdir /nix/var/nix/{gcroots,profiles}/per-user/flokli from now on, or how is this supposed to work on a new system (Nix 2.17.0)?

@thufschmitt
Copy link
Member

@flokli what's your home-manager/Nix version? And what's the exact error you see?

@flokli
Copy link
Contributor

flokli commented Sep 5, 2023

This was home-manager fae8af43e201a8929ce45a5ea46192bbd1ffff18, and Nix 2.17.0.

I didn't set any experimental xdg options in Nix.

The log messages were:

Aug 30 11:55:58 x1 systemd[1]: Starting Home Manager environment for flokli...
Aug 30 11:55:58 x1 hm-activate-flokli[11783]: Starting Home Manager activation
Aug 30 11:55:58 x1 hm-activate-flokli[11783]: Sanity checking Nix
Aug 30 11:55:58 x1 hm-activate-flokli[11783]: Sanity checking oldGenNum and oldGenPath
Aug 30 11:55:58 x1 hm-activate-flokli[11783]: This is a live run
Aug 30 11:55:58 x1 hm-activate-flokli[11783]: Using Nix version: nix-env (Nix) 2.17.0
Aug 30 11:55:58 x1 hm-activate-flokli[11783]: Activation variables:
Aug 30 11:55:58 x1 hm-activate-flokli[11783]:   oldGenNum=231
Aug 30 11:55:58 x1 hm-activate-flokli[11783]:   oldGenPath=/nix/store/05ypwxsrlzbl4kzaj1jnj7abab6p8344-home-manager-generation
Aug 30 11:55:58 x1 hm-activate-flokli[11783]:   newGenPath=/nix/store/rrah84zn1q9z4sf31la52vmilqrpmn73-home-manager-generation
Aug 30 11:55:58 x1 hm-activate-flokli[11783]:   newGenNum=232
Aug 30 11:55:58 x1 hm-activate-flokli[11783]:   genProfilePath=/home/flokli/.local/state/nix/profiles/home-manager
Aug 30 11:55:58 x1 hm-activate-flokli[11783]:   newGenGcPath=/home/flokli/.local/state/home-manager/gcroots/current-home
Aug 30 11:55:58 x1 hm-activate-flokli[11783]:   legacyGenGcPath=/nix/var/nix/gcroots/per-user/flokli/current-home
Aug 30 11:55:58 x1 hm-activate-flokli[11783]: Activating checkFilesChanged
Aug 30 11:55:58 x1 hm-activate-flokli[11783]: Activating checkLinkTargets
Aug 30 11:55:58 x1 hm-activate-flokli[11783]: Activating writeBoundary
Aug 30 11:55:58 x1 hm-activate-flokli[11783]: Activating installPackages
Aug 30 11:55:58 x1 hm-activate-flokli[12120]: installing 'home-manager-path'
Aug 30 11:55:58 x1 hm-activate-flokli[12120]: building '/nix/store/gn83jb0dqdc6i519cjqsqsi9rfmbjdq7-user-environment.drv'...
Aug 30 11:55:58 x1 hm-activate-flokli[12120]: error: opening lock file '/nix/var/nix/profiles/per-user/flokli/profile.lock': No such file or directory
Aug 30 11:55:58 x1 hm-activate-flokli[11783]: Oops, Nix failed to install your new Home Manager profile!
Aug 30 11:55:58 x1 hm-activate-flokli[11783]: Perhaps there is a conflict with a package that was installed using
Aug 30 11:55:58 x1 hm-activate-flokli[11783]: "nix-env -i"? Try running
Aug 30 11:55:58 x1 hm-activate-flokli[11783]:     nix-env -q
Aug 30 11:55:58 x1 hm-activate-flokli[11783]: and if there is a conflicting package you can remove it with
Aug 30 11:55:58 x1 hm-activate-flokli[11783]:     nix-env -e {package name}
Aug 30 11:55:58 x1 hm-activate-flokli[11783]: Then try activating your Home Manager configuration again.
Aug 30 11:55:58 x1 systemd[1]: home-manager-flokli.service: Main process exited, code=exited, status=1/FAILURE
Aug 30 11:55:58 x1 systemd[1]: home-manager-flokli.service: Failed with result 'exit-code'.
Aug 30 11:55:58 x1 systemd[1]: Failed to start Home Manager environment for flokli.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug profiles Versioned gc root symlinks; nix profile, nix-env
Projects
Archived in project
Development

No branches or pull requests

6 participants