Search code examples
nixnixos

How can I reset my nix environment to the original user profile?


I believe I ran nix-env -if example.nix which changed my nix environment.

How can I undo this action?

I'm trying to run a application that is specified in my nixos config (/etc/nixos/*), however it no longer seems available (within the $PATH).


Seems it might be nix-env --switch-profile /nix/var/nix/profiles/default (according to https://nixos.org/nix/manual/#sec-profiles) ?


Solution

  • I run nix-env -e '*' to remove all packages from my profile installed via nix-env regularly and move anything I want to use into environment.systemPackages so all my packages are tracked in my nixos configuration declaratively. As for debugging why the application specified in your configuration.nix isn't in your path, an application specified in your configuration.nix should be symlinked to /run/current-system/sw/bin, so the first thing would be to check that the binary you're looking for is listed in there and second that is in your $PATH.