Difference between installing via nix-env and configuration.nix?

packages listed in configuration.nix get added to a system profile. This also gives you the generations

no, nix-env is meant to give you a similar experience to other package managers, however, i manages it’s own gcroots (what derivations can be cleaned up), and even generations. Generally you should avoid using nix-env for package installation as it doesn’t leverage the power of nix.

Somewhat. In terms of user vs system installation, yes. However, nixos is different from normal FHS operating systems in that there’s a layer of indirection when you install something, so your PATH and other environment variables just reference the current “profile” or generation

$ echo $PATH
/run/wrappers/bin:/home/jon//.nix-profile/bin:/etc/profiles/per-user/jon/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin:/home/jon//.cargo/bin:/home/jon//.config/nixpkgs/bin

/home/jon//.cargo/bin:/home/jon//.config was added by me.

2 Likes