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 install|remove|upgrade|switch|diff|merge|rebuild|generate|list|find|show|history [options]...
PARAMETERS
install
Install a package into the profile.
remove
Remove a package from the profile.
upgrade
Upgrade a package in the profile.
switch
Switch to a specific profile generation.
diff
Show the differences between two profile generations.
merge
Merge two profiles.
rebuild
Rebuild the profile to incorporate changes.
generate
Generate a new profile from a description.
list
List the contents of the profile.
find
Find packages within a profile.
show
Show information about a specific package in the profile.
history
Show the history of profile generations.
--profile path
Specify a custom profile path (default: ~/.nix-profile).
--file file
Specify a Nix expression file to install.
DESCRIPTION
The `nix-profile` command manages user environment profiles in Nix. A profile is a symlink farm located in `~/.nix-profile` (by default). It points to the packages you have installed, making them available in your shell. `nix-profile` allows you to install, uninstall, and upgrade packages within a profile without affecting the system globally.
Profiles are immutable once created. When you 'install' something, a new profile is created and atomically activated, ensuring a consistent environment. `nix-profile` is a user-specific command, meaning changes only impact the user running it. It simplifies managing dependencies and versions for different projects, offering reproducible and isolated environments.
CAVEATS
The environment variables set by the profile (e.g., PATH) might not take effect immediately in existing shell sessions. You may need to open a new terminal or source the profile's shell script to refresh them. `nix-profile` relies on the Nix store for package management and garbage collection.
PROFILE GENERATIONS
Each time you install, remove, or upgrade packages with `nix-profile`, a new profile generation is created. You can switch between these generations using the `nix-profile switch` command, allowing you to revert to previous states if necessary.
ENVIRONMENT VARIABLES
To ensure packages installed via `nix-profile` are accessible, environment variables like PATH are modified. You can source the profile's shell script (e.g., `~/.nix-profile/etc/profile.d/nix.sh`) to update your current shell's environment.
HISTORY
The `nix-profile` command is a core component of the Nix package manager. It was designed to provide a user-friendly interface for managing software installations and dependencies in an isolated and reproducible manner. It evolved alongside Nix itself, addressing the need for per-user environment management.