Evertras/simple-homemanager

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

Opened this issue · 5 comments

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.

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.

@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!

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.

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 commented

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.