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

01 home-manager install missing additional setup on multi-user install on foreign distro. #2

Open
brisk-pm opened this issue Feb 25, 2024 · 11 comments
Labels
troubleshooting Reference for others to help fix a problem

Comments

@brisk-pm
Copy link

The instructions linked to install home-manager
point the user to install home-manager with
nix-shell '<home-manager>' -A install

In order to progress I had to add a nixpkgs channel and update the $NIX_PATH in my environment:

nix-channel --add https://nixos.org/channels/nixpkgs-unstable nixpkgs
export NIX_PATH=$NIX_PATH:$HOME/.nix-defexpr/channels

Also using the nix-shell install method wiped the home-manager path after the first make command that runs home-manager switch.

I was able to get home-manager persistently available with nix profile install home-manager. I'm not sure if this my unfamiliarity with nix or if the instructions are unclear for a multi-user nix install on a foreign distro.

@Evertras
Copy link
Owner

Evertras commented Mar 5, 2024

Mentioned this in the nixos discourse forums as well, but for visibility repeating:

I'm a little wary of adding too much troubleshooting to the guide itself. I'd rather leave that to the docs with the tools, because everyone's going to have a different specific setup.

I'd actually like to leave this issue open as something others can reference, to act as a troubleshooting supplement.

@Evertras Evertras added bug Something isn't working troubleshooting Reference for others to help fix a problem and removed bug Something isn't working labels Mar 5, 2024
@davidjmeier
Copy link

davidjmeier commented Mar 6, 2024

@brisk-pm I ran into the same issue. I believe the issue is that the nix-shell '<home-manager>' -A install command, as I understand it, works by creating a temporary environment.

The nix profile install home-manager will install it directly into a permanent environment and in the default profile.

I believe the other way around this, and I think is probably the correct way if someone wants to do this declaratively, is by making sure home.nix has the home-manager application in it. I would say that the guide should modify the first iteration of home.nix to include it, by default, and explain that the instantiation is temporary and the way to make this stick is to encode it into your home.nix. I could be wrong, being new to Nix - but that's my takeaway. The snippet in home.nix I'm referring to editing in the first iteration would instead look like this...

...
  home = {
    packages = with pkgs; [
       home-manager
       hello
    ];
...

All that being said, thanks for a fantastic to-the-point guide @Evertras!

@brisk-pm
Copy link
Author

brisk-pm commented Mar 6, 2024

Ah, I see we can make home-manager permanent as part of the initial home-manager switch

I like the generic way of bootstrapping home-manager with nix-shell -p home-manager (or equivalent) and adding the home-manager package via home.nix. We do not have to source any profile things this way.

Tested on a fresh NixOS install. I really appreciate this guide's encapsulation of home-manager in a flake. Its portable between foreign distros and NixOS.

@Evertras
Copy link
Owner

Evertras commented Mar 9, 2024

I think there's some merit to having home manager bootstrap itself, but I'd also be wary. If you accidentally delete home manager from the list (for example, forgetting to include a module that lists it while refactoring things), then you're going to get into weird states of trying to restore it. Successfully setting up the standalone version makes this much less of a hassle.

Because of that I'd rather not put that directly in the guide, but I'm happy to have this issue open as discussion for others to see as other options.

@bj0
Copy link

bj0 commented Jul 1, 2024

Since you have flakes enabled, you don't actually need to install home-manager to use it, you can simply nix run home-manager/<branch> -- switch --flake .#myprofile the first time (see https://nix-community.github.io/home-manager/index.xhtml#sec-flakes-standalone). It can then self bootstrap if you put it in home.nix, and if you accidentally delete it, you can run from git again to fix it.

This simplifies the installation steps quite a bit.

@jameshulse
Copy link

Excellent guide. But I'm stuck in the exact same way. After running make for the first time home-manager is no longer found.

How is it meant to work in non-NixOS environments? I can see "home-manager-path" as an installed package.

I'm also stuck because I don't actually know how to deactivate my profile to even add "home-manager" to my packages list (if I have to solve this the less correct way).

@Evertras
Copy link
Owner

Evertras commented Sep 1, 2024

I actually use @bj0 's solution in my personal setup, I may add that to the guide officially at this point as this seems to be a painful bit.

@jameshulse
Copy link

Fantastic. Yes I think that is a good solution. Or at least as a completely new user it is useful to realise that arbitrary commands can be run like that.

I ended up adding home-manager to my packages list which helped. But as you said, there is slightly more risk to that if you don't realise the escape hatch of running it directly with nix run ....

@sharksforarms
Copy link

Ran into this issue too, I got

$ home-manager switch --flake .#myprofile
/bin/sh: 1: home-manager: not found
make: *** [Makefile:3: update] Error 127

after the first switch.

After reading https://nix-community.github.io/home-manager/ I found that you can simply do:

  # Let Home Manager install and manage itself.
  programs.home-manager.enable = true;

@sheluchin
Copy link

I'm also stuck on this same step. After running make the first time, home-manager isn't found. I've tried some of the above to no avail. Any update on the instructions?

@jameshulse
Copy link

I'm also stuck on this same step. After running make the first time, home-manager isn't found. I've tried some of the above to no avail. Any update on the instructions?

I think the most recent comment that shows how to enable home manager should work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
troubleshooting Reference for others to help fix a problem
Projects
None yet
Development

No branches or pull requests

7 participants