I would like to point $NIX_PATH to ~/.nix-defexpr/channels instead of ~/.nix-defexpr/channels_root as currently. I don't want to have to type that every time I run nix-env. What's the right way of doing that?


I would simply define the variable the way you want it in your ~/.profile.

  • 1
    And give up statelessness? – dmvianna Feb 18 '18 at 21:02
  • What statelessness? You update channels "imperatively" - that's how they're designed, so that by default you install from the latest-updated channel without having to specify e.g. the exact commit hash. – Vladimír Čunát Feb 19 '18 at 18:14
  • 1
    Yes, but we try to keep the state in /etc/nixos/configuration.nix and not all over the place like in a regular Linux distro. I am hoping to have a tidy solution with which I can make a reproducible recipe. I may be using that to create cloud instances, or sharing configuration with colleagues. – dmvianna Feb 20 '18 at 10:50
  • 1

I still want to know how to do it via configuration, but imperatively through an expression written in a file I can do

$ nix-env -if /this/file.nix -I ~/.nix-defexpr/channels

This way I'll be using the user's channels. Without it ~/.nix-defexpr/channels_root is read instead. Which is what I'm trying to avoid here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.