Check out https://stop-using-nix-env.privatevoid.net/ for some quick explanations on why nix-env
should be avoided in (almost) all cases. Much more detailed discussion is in this thread.
For your specific questions:
- On why
nix-env
exists in the first place:
It is useful as a “low-level” plumbing command for other tools (e.g. Home Manager). These tools (should) have a high-level API that retains one of Nix’s main features: being able to define your NixOS configuration (among other things) in configuration files, written in a declarative language. - Benefits of Nix:
As stated in the first point, one of Nix’s primary strengths is its use of declarative configurations. In practice, for NixOS, this means (nearly) the entire operating system is defined in/etc/nixos/configuration.nix
and whatever other filesconfiguration.nix
imports. This declarative approach has many benefits, which I assume you are already aware of since you’re already experimenting with NixOS. Usingnix-env
instead of modifying/etc/nixos/configuration.nix
to permanently install things go completely against this idea. But see below for temporary installations… - On long build times:
When you add new packages to/etc/nixos/configuration.nix
there is not much you can do to reduce the potentially long processing time. Subsequentnixos-rebuild switch
commands that you run just to update already-installed packages should complete fairly quickly. If you want to install something temporarily, use ephemeral shells.