this post was submitted on 27 Jan 2026
8 points (100.0% liked)

Nix / NixOS

2623 readers
14 users here now

Main links

Videos

founded 2 years ago
MODERATORS
 

I'm trying to get my scripts to have precedence over the home manager stuff.

Do you happen to know how to do that?

(not sure it's relevant, but I'm using home-manager in tumbleweed, not nixos)


edit:

Thanks for the replies - I finally got time to investigate this properly so here's a few notes (hopefully useful for someone somehow).

~/.nix-profile/bin is added (prepended) to the path by the files in /nix/var/nix/profiles/default/etc/profile.d/, sourced every time my shell (fish, but it should be the same for others) starts (rg -L nix/profiles /etc 2> /dev/null for how they are sourced).

The path I set in homemanager (via home.sessionPath, which is added (prepended) to home.sessionSearchVariables.PATH) ends up in .nix-profile/etc/profile.d/hm-session-vars.sh, which is sourced via ~/.profile once per session (I think? certainly not when I start fish or bash). This may be due to how I installed home-manager... I don't recall.

So... the solution is to set the path again in my shell (possibly via programs.fish.shellInitLast - I din't check yet).

top 3 comments
sorted by: hot top controversial new old
[–] Oinks@lemmy.blahaj.zone 4 points 2 weeks ago

As far as I'm aware Home Manager doesn't set PATH at all, though the Nix installer does. I'm not sure where it adds to the PATH, it might edit /etc/profile or something like that. You should be able to change it since you're not on NixOS.

Alternatively this should also do the trick, although it's a bit ugly:

home.sessionVariables.PATH = "$HOME/.local/bin:$PATH";
[–] stupiv@lemmy.ml 3 points 2 weeks ago* (last edited 2 weeks ago)
  programs.fish.enable = true; # Enable your shell
  home.sessionPath = ["$HOME/.local/bin"];

I found the option by searching for "PATH" at home-manager-options.extranix.com.

home.sessionPath will generate hm-session-vars files for different shells. You can read it by cat ~/.nix-profile/etc/profile.d/hm-session-vars.sh.

Enabling the shell is required for the respective hm-session-vars file to be sourced into the shell.

[–] devils_dust@lemmygrad.ml 1 points 2 weeks ago

You could use a shell dotfile (.bashrc for instance) for that.

Home manager even allows you to manage them through it, via https://nix-community.github.io/home-manager/options.xhtml#opt-home.file