diff --git a/doc/manual/nix-env.xml b/doc/manual/nix-env.xml index a5217450b5..ff9f9c16a2 100644 --- a/doc/manual/nix-env.xml +++ b/doc/manual/nix-env.xml @@ -93,11 +93,10 @@ also . Specifies the profile to be used by those operations that operate on a profile (designated below as the - active profile). A profile is sequence of + active profile). A profile is a sequence of user environments called generations, one of - which is the current generation. The default - profile is the target of the symbolic link - ~/.nix-profile (see below). + which is the current + generation. @@ -1256,6 +1255,16 @@ error: no generation older than the current (91) exists Environment variables + + NIX_PROFILE + + Location of the Nix profile. Defaults to the + target of the symlink ~/.nix-profile, if it + exists, or /nix/var/nix/profiles/default + otherwise. + + + diff --git a/src/nix-env/nix-env.cc b/src/nix-env/nix-env.cc index b57e54c758..68a3e89d8c 100644 --- a/src/nix-env/nix-env.cc +++ b/src/nix-env/nix-env.cc @@ -1350,6 +1350,9 @@ void run(Strings args) if (!op) throw UsageError("no operation specified"); + if (globals.profile == "") + globals.profile = getEnv("NIX_PROFILE", ""); + if (globals.profile == "") { Path profileLink = getHomeDir() + "/.nix-profile"; globals.profile = pathExists(profileLink)