Add Directory to PATH

I want to add a directory to the path variable, so I can access the programs from terminal in my home shell and also in a nix shell. It would be best if the path “extension” is only specified for one user. I’m using fish as my home shell, but the nix shells are using bash and it should work for both.
I already searched my ass off, but couldn’t find anything useful. I found environment.variables but I couldn’t get it working/ figure out how it works.
I’m new to NixOS, so please be understanding.

Generally, NixOS doesn’t manage user configuration - for that, you can use home-manager, or just do things like on any other distro (i.e. useing .profile or the fish equivalent of .bashrc).

1 Like

Thanks, using home manager solved the issue. Had to set

  programs.bash.enable = true;
  programs.zsh.enable = true;
  programs.fish.enable = true;

and then I could do

  home.sessionPath = [
    "<Path to my directory>"
  ];

Another way was to package your scripts and add them to home.packages or users.users.*.packages for “user only” or indeed environment.systemPackages for everyone.

1 Like