nix-profile
Manage user environment package installations and upgrades
TLDR
Install some packages from nixpkgs into the default profile
Install a package from a flake on GitHub into a custom profile
List packages currently installed in the default profile
Remove a package installed from nixpkgs from the default profile, by name
Upgrade packages in the default to the latest available versions
Rollback (cancel) the latest action on the default profile
SYNOPSIS
nix-profile [options...] subcommand [subcommand-options...] [arguments...]
PARAMETERS
install
Adds packages to the user profile. For example: nix-profile install nixpkgs#htop
remove
Removes packages from the user profile. For example: nix-profile remove nixpkgs#htop
update
Updates the Nix channels used for package lookups, fetching the latest package definitions.
upgrade
Upgrades packages in the profile to their latest available versions according to the current channels.
list
Lists all packages currently installed in the active user profile.
rollback
Reverts the user profile to a previous generation, effectively undoing recent changes.
generations
Displays the history of all user profile generations, including their creation times and status. (Alias for history)
wipe-history
Deletes older profile generations, freeing up disk space. Use with caution as it prevents rollback to those generations.
set-default
Sets a specific generation as the default for the user profile, controlling which software is active.
DESCRIPTION
The nix-profile command, often superseded by the newer nix profile subcommand of the unified nix CLI, is fundamental to managing user-specific software environments within the Nix package manager. It allows non-root users to install, upgrade, and remove packages without affecting the system-wide installation or other users.
At its core, nix-profile manages a "profile" which is a symlink tree pointing to a specific "generation" of installed packages. Each modification (install, upgrade, remove) creates a new generation, enabling easy rollback to previous states. This declarative approach ensures reproducibility and isolation of user environments, making it a powerful tool for managing personal software installations.
CAVEATS
Managing profiles can consume significant disk space if old generations are not regularly garbage collected. While powerful for user environments, nix-profile does not manage global system configurations or services; that's handled by NixOS or Nix's declarative system management.
Be aware of the distinction between the legacy nix-profile command and the modern nix profile subcommand (part of the unified nix CLI). While functionally similar, the modern command offers improved syntax and integration within the broader Nix ecosystem.
GENERATIONS
Each successful operation that modifies the user profile (e.g., install, upgrade, remove) creates a new "generation." A generation is a complete, atomic snapshot of the user's installed software environment. This allows users to effortlessly switch between different versions of their environment or revert to a previous state, providing robust rollback capabilities and ensuring reproducibility.
PACKAGE SPECIFICATION
Packages are typically specified using the format nixpkgs#package-name when using flakes. This refers to a package named 'package-name' from the nixpkgs channel. You can also specify packages from other Nix flakes or direct paths to derivations. For older `nix-profile` usage, simply `package-name` would often suffice after setting up channels.
LEGACY VS. UNIFIED CLI
The command nix-profile refers to the legacy Nix CLI command. Its functionality is largely mirrored and often improved upon by the nix profile subcommand within the unified nix command (e.g., `nix profile install nixpkgs#htop`). Users are generally encouraged to use the unified nix CLI for modern Nix operations due to its consistency and feature set.
HISTORY
The concept of user profiles and generations has been central to Nix's design since its early days, providing a robust mechanism for managing user-specific software environments. The original Nix CLI exposed this functionality primarily through commands like nix-env and later nix-profile. With the advent of the unified nix command-line interface (introduced around Nix 2.0), much of nix-profile's functionality was integrated into the new nix profile subcommand, simplifying the overall user experience and command structure. While nix-profile still exists for compatibility, nix profile is the recommended modern approach for managing user environments.
SEE ALSO
nix(1), nix-env(1), nix-store(1), nix-collect-garbage(1)