diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2012-12-12T15·01+0100 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2012-12-12T15·01+0100 |
commit | 9fa12fc2015c9cbc34bcf9d83e7396ba5dbc81a9 (patch) | |
tree | 388441a167bcde8c56d16a21d0eaa246c86c1c53 | |
parent | 3ad53e43c8ca35cc581ebc3dd880c11892c8e016 (diff) |
Allow setting the profile location using $NIX_PROFILE
Fixes #69.
-rw-r--r-- | doc/manual/nix-env.xml | 17 | ||||
-rw-r--r-- | 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 a5217450b5a3..ff9f9c16a2cb 100644 --- a/doc/manual/nix-env.xml +++ b/doc/manual/nix-env.xml @@ -93,11 +93,10 @@ also <xref linkend="sec-common-options" />.</phrase></para> <listitem><para>Specifies the profile to be used by those operations that operate on a profile (designated below as the - <emphasis>active profile</emphasis>). A profile is sequence of + <emphasis>active profile</emphasis>). A profile is a sequence of user environments called <emphasis>generations</emphasis>, one of - which is the <emphasis>current generation</emphasis>. The default - profile is the target of the symbolic link - <filename>~/.nix-profile</filename> (see below).</para></listitem> + which is the <emphasis>current + generation</emphasis>.</para></listitem> </varlistentry> @@ -1256,6 +1255,16 @@ error: no generation older than the current (91) exists</screen> <refsection condition="manpage"><title>Environment variables</title> <variablelist> + + <varlistentry><term><envar>NIX_PROFILE</envar></term> + + <listitem><para>Location of the Nix profile. Defaults to the + target of the symlink <filename>~/.nix-profile</filename>, if it + exists, or <filename>/nix/var/nix/profiles/default</filename> + otherwise.</para></listitem> + + </varlistentry> + <xi:include href="env-common.xml#xmlns(db=http://docbook.org/ns/docbook)xpointer(//db:variablelist[@xml:id='env-common']/*)" /> </variablelist> diff --git a/src/nix-env/nix-env.cc b/src/nix-env/nix-env.cc index b57e54c758f6..68a3e89d8c7e 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) |