vuls: init at 0.27.0
[NixPkgs.git] / nixos / doc / manual / configuration / ad-hoc-packages.section.md
blobe9d574903a104afb92070e6865ee863e3d8450ad
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:
6 ```ShellSession
7 $ nix-env -iA nixos.thunderbird
8 ```
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:
23 ```ShellSession
24 $ nix-channel --update nixos
25 ```
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
32 version by doing:
34 ```ShellSession
35 $ nix-env -u '*'
36 ```
38 A package can be uninstalled using the `-e` flag:
40 ```ShellSession
41 $ nix-env -e thunderbird
42 ```
44 Finally, you can roll back an undesirable `nix-env` action:
46 ```ShellSession
47 $ nix-env --rollback
48 ```
50 `nix-env` has many more flags. For details, see the nix-env(1) manpage or
51 the Nix manual.