I’m very new to Nix, having installed NixOS 22.05 yesterday. I figured I’d play around with Home Manager (as I’d like my config to be somewhat portable to macOS, I don’t view my “home” setup to be particularly tightly tied to my system configuration, etc.). So, I’m attempting to install using the “standalone” instructions at Home Manager Manual
I run into a problem related to NIX_PATH straight away. Am I holding NixOS or Home Manager wrong?
According to the instructions the following should work on NixOS:
$ nix-channel --add https://github.com/nix-community/home-manager/archive/release-22.05.tar.gz home-manager
$ nix-channel --update
unpacking channels...
$ nix-channel --list
home-manager https://github.com/nix-community/home-manager/archive/release-22.05.tar.gz
$ nix-shell '<home-manager>' -A install
error: file 'home-manager' was not found in the Nix search path (add it using $NIX_PATH or -I)
The docs say that for non-NixOS I should execute this in my shell:
…and indeed when I do the same it fixes the problem. But if NIX_PATH is needed, why isn’t this set up for me automatically on NixOS? I’m running a near vanilla NixOS 22.05 as installed via the GUI installer. Is there something I should be doing differently?
Thanks @tejing, good to know how it is working for others.
More details: I’m running Gnome and using Gnome Terminal. My understanding is that this combination will not source /etc/profile at any point, and this is by (Gnome’s) design. See Initiatives/Wayland/SessionStart - GNOME Wiki!. Gnome Terminal doesn’t start login shells by default (although this is an option). Apparently environment.d is the new hotness for setting up default environment variables.
Short-term, you can probably get away with just adding . /etc/set-environment to your ~/.bashrc, but that might come back to bite you later. I know zip about wayland or gnome, so I can’t help you there, but the ideal solution is to make sure your desktop environment is running with /etc/set-environment sourced. Lots of nixos modules will expect that path to work, so it’s definitely a bug if it doesn’t. What display manager are you using? At least with lightdm, it’s actually part of the display manager config that makes sure /etc/profile is sourced before the session is started.
Had time to look at this again and when I install https://channels.nixos.org/nixos-22.05/latest-nixos-gnome-x86_64-linux.iso into a VM and do nothing but install gnome-terminal from there, all is well (i.e. NIX_PATH is set in the shells it runs). So, likely, this was something with my personal dotfiles or some such.
Good to know. I suspected there was an element specific to you involved somehow, since that seemed like a little too major a piece to be broken, if it happened in gnome generally.