6

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) ?

Chris Stryczynski
  • 30,145
  • 48
  • 175
  • 286
  • Re: "undo this action" -- `nix-env --rollback`, if that's the most recent operation you did. – Charles Duffy Dec 23 '18 at 16:59
  • You might also want to run `nix-env --list-generations` to get a rough idea of which generation you want to go back to. – chepner Dec 23 '18 at 17:17
  • And you can pick a particular generation via `nix-env -G gen-number-goes-here`. If you mess up your config this comes in handy. Once you go back to a previous generation any subsequent changes to _that_ generation will create a newest generation and you can continue on from there. It is great being able to rollback. – Joe Dec 22 '19 at 17:03

1 Answers1

12

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.

Samuel Leathers
  • 326
  • 5
  • 9