name: nix-profile
description: Manage Nix profiles using the modern nix profile command (experimental, replaces nix-env). Use when installing, removing, upgrading, or managing packages with Nix flakes.
Nix Profile
Manage Nix profiles using the modern nix profile command (experimental,
replaces nix-env).
Overview
nix profile is the modern, flake-native way to manage Nix profiles. It
replaces the older nix-env command with a more intuitive interface built
around flakes.
Warning: Once you use nix profile, you cannot use nix-env on the same
profile without first deleting it.
Profile Location
Profiles are stored at:
$XDG_STATE_HOME/nix/profiles/profile(default for regular users)$NIX_STATE_DIR/profiles/per-user/root/profile(for root)
The active profile is symlinked at:
~/.nix-profile(traditional)$XDG_STATE_HOME/nix/profile(ifuse-xdg-base-directoriesis enabled)
Commands
Install a package
nix profile add nixpkgs#hello
nix profile add nixpkgs/release-23.11#hello
nix profile add nixpkgs/d73407e8e6002646acfdef0e39ace088bacc83da#hello
nix profile add nixpkgs#bash^man # specific output
Alias: nix profile install (same as add)
List installed packages
nix profile list
Shows:
- Name (used for remove/upgrade)
- Flake attribute path
- Original and locked flake URLs
- Store paths
Remove packages
nix profile remove hello # by name
nix profile remove --all # remove everything
nix profile remove --regex '.*vim.*' # by regex
nix profile remove /nix/store/...-hello # by store path
Upgrade packages
nix profile upgrade hello # upgrade specific package
nix profile upgrade --all # upgrade everything
nix profile upgrade --regex '.*vim.*' # upgrade matching packages
Note: Only works with unlocked flake references (e.g., nixpkgs#hello). Locked references (full git rev) won't upgrade.
View profile history
nix profile history
Shows changes between profile versions (additions, removals, upgrades).
Roll back changes
nix profile rollback # roll back to previous version
nix profile rollback --to 510 # roll back to specific version
Show closure differences
nix profile diff-closures
Shows detailed differences between profile versions including all dependencies.
Clean up old versions
nix profile wipe-history # delete all non-current versions
nix profile wipe-history --older-than 30d # delete versions older than 30 days
nix profile wipe-history --dry-run # preview what would be deleted
Common Options
--profile /path/to/profile- operate on a custom profile path--priority N- set package priority (lower = higher priority)--dry-run- show what would happen without making changes
Migration from nix-env
If you need to go back to nix-env:
# Warning: this deletes all installed packages
rm -rf "${XDG_STATE_HOME:-$HOME/.local/state}/nix/profiles/profile"
Key Differences from nix-env
| Feature | nix-env | nix profile |
|---|---|---|
| Flake-native | No | Yes |
| Profile format | manifest.nix | manifest.json |
| Install command | nix-env -iA nixpkgs.hello |
nix profile add nixpkgs#hello |
| Remove by name | nix-env -e hello |
nix profile remove hello |
| Upgrade | nix-env -u |
nix profile upgrade --all |
| List | nix-env -q |
nix profile list |
Filesystem Layout
~/.local/state/nix/profiles/
├── profile -> profile-7-link # current profile symlink
├── profile-5-link -> /nix/store/...-profile # old version
├── profile-6-link -> /nix/store/...-profile # old version
└── profile-7-link -> /nix/store/...-profile # current version
Each profile version contains:
bin/- symlinks to installed package binariesshare/- shared filesmanifest.json- profile manifest