From 9fa12fc2015c9cbc34bcf9d83e7396ba5dbc81a9 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 12 Dec 2012 16:01:46 +0100 Subject: [PATCH] Allow setting the profile location using $NIX_PROFILE Fixes #69. --- doc/manual/nix-env.xml | 17 +++++++++++++---- src/nix-env/nix-env.cc | 3 +++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/doc/manual/nix-env.xml b/doc/manual/nix-env.xml index a5217450b..ff9f9c16a 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 b57e54c75..68a3e89d8 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)