Use case → Coding simple stuff I am trying & changing constantly. I would not install it at every single change but want to be able to call these commands directly.
In another OS I could add the various bin or shell to the $PATH , or directly create symlinks from /usr/bin to these few projects.
What is a quick but proper way in NixOS? I would add in the NixOS configuration few lines about this specific user to complete his $PATH? I have home-manager installed from previous trials, I could maybe rather use this I bet ? Or is there a somewhat simpler way to enrich path?
Sorry if the answer is obvious, I looked at few docs but honnestly answers here are generally more interesting
The existing answers don’t really help with this use case, since they all imply rebuilding your NixOS configuration on every change.
If you want a really low-friciton way of just getting a binary in $PATH, just do that. It’s perfectly reasonable to add ~/.local/bin to $PATH, and just symlink your binaries into there. It’s not “proper”, in that it’s not reproducible, but with stuff you just have lying around locally in directories that won’t be true anyway.
Once you’re ready to make those things more permanent you should package them and install them just like any other package; depending on the languages you write your mini projects in, this will look different.
I would not recommend manually symlinking stuff to /usr/bin even on other distros. Use ~/.local/bin.
Without this, home-manager cannot control your user’s $PATH.
If using it with NixOS things should just work, however you might not notice the home-manager activation script failing. This is pretty common on new installations because it will refuse to overwrite existing files. Check journalctl --user -e after running the switch.
It’s also quite possible that fish doesn’t source the default path that home-manager sets your env variables in. I don’t use fish, I don’t know how the default NixOS fish configuration works and I don’t know if your configuration overrides default behavior.
Oh you are a genius. Or maybe am I stupid haha. Anyway
I use home manager with NixOS. Happy to read it is recommended. I remember I hesitated because rebuilding just home seemed a useful feature, but anyway my HM usage is very limited and just started in order to try hyprland.
… And actually the HM sessionPath worked like a charm! As you bet, fish does ignore it. I ran a bash session and the $PATH was properly set. Not a very good point for fish - but I probably forgot to read about it somewhere.
So HM seems very convenient for someone not using fish, while fish users may use for example set -U fish_user_paths . I will investigate pkgs.writeShellScript later.