Allow setting the profile location using $NIX_PROFILE

Fixes #69.
This commit is contained in:
Eelco Dolstra 2012-12-12 16:01:46 +01:00
parent 3ad53e43c8
commit 9fa12fc201
2 changed files with 16 additions and 4 deletions

View file

@ -93,11 +93,10 @@ also <xref linkend="sec-common-options" />.</phrase></para>
<listitem><para>Specifies the profile to be used by those <listitem><para>Specifies the profile to be used by those
operations that operate on a profile (designated below as the 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 user environments called <emphasis>generations</emphasis>, one of
which is the <emphasis>current generation</emphasis>. The default which is the <emphasis>current
profile is the target of the symbolic link generation</emphasis>.</para></listitem>
<filename>~/.nix-profile</filename> (see below).</para></listitem>
</varlistentry> </varlistentry>
@ -1256,6 +1255,16 @@ error: no generation older than the current (91) exists</screen>
<refsection condition="manpage"><title>Environment variables</title> <refsection condition="manpage"><title>Environment variables</title>
<variablelist> <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']/*)" /> <xi:include href="env-common.xml#xmlns(db=http://docbook.org/ns/docbook)xpointer(//db:variablelist[@xml:id='env-common']/*)" />
</variablelist> </variablelist>

View file

@ -1350,6 +1350,9 @@ void run(Strings args)
if (!op) throw UsageError("no operation specified"); if (!op) throw UsageError("no operation specified");
if (globals.profile == "")
globals.profile = getEnv("NIX_PROFILE", "");
if (globals.profile == "") { if (globals.profile == "") {
Path profileLink = getHomeDir() + "/.nix-profile"; Path profileLink = getHomeDir() + "/.nix-profile";
globals.profile = pathExists(profileLink) globals.profile = pathExists(profileLink)