1 # Ad-Hoc Package Management {#sec-ad-hoc-packages}
3 With the command `nix-env`, you can install and uninstall packages from
4 the command line. For instance, to install Mozilla Thunderbird:
7 $ nix-env -iA nixos.thunderbird
10 If you invoke this as root, the package is installed in the Nix profile
11 `/nix/var/nix/profiles/default` and visible to all users of the system;
12 otherwise, the package ends up in
13 `/nix/var/nix/profiles/per-user/username/profile` and is not visible to
14 other users. The `-A` flag specifies the package by its attribute name;
15 without it, the package is installed by matching against its package
16 name (e.g. `thunderbird`). The latter is slower because it requires
17 matching against all available Nix packages, and is ambiguous if there
18 are multiple matching packages.
20 Packages come from the NixOS channel. You typically upgrade a package by
21 updating to the latest version of the NixOS channel:
24 $ nix-channel --update nixos
27 and then running `nix-env -i` again. Other packages in the profile are
28 *not* affected; this is the crucial difference with the declarative
29 style of package management, where running `nixos-rebuild switch` causes
30 all packages to be updated to their current versions in the NixOS
31 channel. You can however upgrade all packages for which there is a newer
38 A package can be uninstalled using the `-e` flag:
41 $ nix-env -e thunderbird
44 Finally, you can roll back an undesirable `nix-env` action:
50 `nix-env` has many more flags. For details, see the nix-env(1) manpage or