Nix command/profile

From NixOS Wiki
Jump to: navigation, search

This article is about the nix profile subcommand.

Warning: Be careful when testing. Once you have used nix profile you can no longer use nix-env without first deleting /nix/var/nix/profiles/per-user/$USER/profile

This feature also requires ca-references in nix to be enabled.

{ pkgs, ... }: {
   nix.extraOptions = ''
      experimental-features = nix-command ca-references
   '';
}

Description

Imperative package management (upcoming replacement for nix-env)

Usage

$ nix profile COMMAND FLAGS... ARGS...

Flags

no flags at the moment

Available commands

nix profile info

List installed packages.

nix profile install

Install a package into a profile.

nix profile remove

Remove packages from a profile.

nix profile upgrade

Upgrade packages using their most recent flake

Switching between nix-env and nix profile

Once you installed a package with nix profile, you get the following error message when using nix-env:

$ nix-env -f '<nixpkgs>' -iA 'hello'
error: --- Error ----------------------------------------------------------------------------------------------------------------- nix-env
profile '/nix/var/nix/profiles/per-user/joerg/profile' is incompatible with 'nix-env'; please use 'nix profile' instead

To migrate back to `nix-env` you can delete your current profile:

Warning: This will delete what packages have been installed before so you may want to make a back-up of this information before.
$ rm -rf /nix/var/nix/profiles/per-user/$USER/profile

See also