My usual process of installing things on NixOS is changing my configuration.nix, executing nixos-rebuild switch, rebooting, and choosing the new (last) OS generation.

I know it is also possible to install packages via nix-shell (but I have never used it).

What are the differences between the two options? When one is more appropriate than the other?

  • 2
    Btw. nixos-rebuild switch will apply the changes at runtime. As long as you don't touch things like mounts or upgrade core things like the kernel, you don't need to reboot. Also, the bootloader will automatically have the latest generation preselected.
    – Atemu
    Jul 29, 2022 at 19:46

1 Answer 1


nix-shells are for ephemeral environments that you don't necessarily want to keep.
I.e. you heard about this cool new tool you want to try out, so you open a nix-shell and run it from there. The tool will only be part of that one shell's environment. Other shells will not be able to find it.

If the tool wasn't to your liking, you would be sure that A. it isn't polluting the rest of your environment and B. after you close the nix-shell again, the next garbage collection will free up the space it took.

If however you do like it and want it to be permanent part of your environment, that's when you add it to environment.systemPackages.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .