How to add a dir to my system's (or user's) PATH?

Hey there. First time NixOS user here :slight_smile:

The first thing that I’ve tried to do was to setup Python 3. I’ve added “python3” to my system packages and rebuilt my environment. It worked flawlessly!

Then, I’ve noticed that “pip” is not available. I could look for something like “python3-pip” in Nix, but I figured I could just use my local env as well:

python -m ensurepip --upgrade

Everything worked and pip was installed to .local/bin, and I’ve noticed that this dir is not in my PATH. What’s the NixOS way of adding .local/bin to my PATH? I searched a lot in the docs for this answer but couldn’t find it.

Hi :wave:
User settings is not managed fully. I’m not aware of any options for setting per-user paths at least. Maybe you can use environment.extraInit or environment.pathsToLink, but not sure if you’d like to inject your user’s local bin to system PATH.

Another option is to just adding it to your shell config.

home-manager (which is a tool you might want to check if you want to declare such stuff) handles it via " home.sessionPath ".

In this case it’s such a common need that there’s a dedicated configuration option for it:


Add ~/.local/bin/ to $PATH

Default: false

1 Like