| 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 (if use-xdg-base-directories is 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
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
nix profile remove --all
nix profile remove --regex '.*vim.*'
nix profile remove /nix/store/...-hello
Upgrade packages
nix profile upgrade hello
nix profile upgrade --all
nix profile upgrade --regex '.*vim.*'
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
nix profile rollback --to 510
Show closure differences
nix profile diff-closures
Shows detailed differences between profile versions including all dependencies.
Clean up old versions
nix profile wipe-history
nix profile wipe-history --older-than 30d
nix profile wipe-history --dry-run
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:
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 binaries
share/ - shared files
manifest.json - profile manifest