Set nixpkgs in NIX_PATH without clobbering other variables

I’d like to change nixpkgs to point to a local git checkout in /Computer/nixpkgs. I’m aware of the -I option, which works great, but I’d like to set NIX_PATH so I don’t have to pass the flag every time. I found this thread: Supported way to set NIX_PATH, and the approach here is great, but unfortunately this completely clobbers other variables.

Right now, my solution is:

> echo $NIX_PATH                                                                   
> export NIX_PATH=${NIX_PATH/nixpkgs=\/nix\/var\/nix\/profiles\/per-user\/root\/channels\/nixos/nixpkgs=\/Computer\/nixpkgs}
> echo $NIX_PATH                                                                                                            

What’s the idiomatic way to do this in configuration.nix? Thanks!

How are these other values set? The default for nix.nixPath appears to be [ "nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos" "nixos-config=/etc/nixos/configuration.nix" "/nix/var/nix/profiles/per-user/root/channels" ] so you should be able to just set it similar the approach you linked, and then however you’re inserting ssh-config-file should still work.

1 Like

Ah, doh, didn’t even realize my own code was adding ssh-config-file, makes sense thanks!