forked from lix-project/lix
* nix-build: put the temporary derivation symlink in a temporary
directory rather than the current directory. * nix-build: --drv-link now implies --add-drv-link.
This commit is contained in:
parent
7ae763e16b
commit
2a3f4110c5
|
@ -21,17 +21,11 @@
|
||||||
</author>
|
</author>
|
||||||
|
|
||||||
<copyright>
|
<copyright>
|
||||||
<year>2004</year>
|
<year>2004-2012</year>
|
||||||
<year>2005</year>
|
|
||||||
<year>2006</year>
|
|
||||||
<year>2007</year>
|
|
||||||
<year>2008</year>
|
|
||||||
<year>2009</year>
|
|
||||||
<year>2010</year>
|
|
||||||
<holder>Eelco Dolstra</holder>
|
<holder>Eelco Dolstra</holder>
|
||||||
</copyright>
|
</copyright>
|
||||||
|
|
||||||
<date>August 2010</date>
|
<date>January 2012</date>
|
||||||
|
|
||||||
</info>
|
</info>
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,8 @@
|
||||||
</group>
|
</group>
|
||||||
<replaceable>attrPath</replaceable>
|
<replaceable>attrPath</replaceable>
|
||||||
</arg>
|
</arg>
|
||||||
<arg><option>--add-drv-link</option></arg>
|
|
||||||
<arg><option>--drv-link </option><replaceable>drvlink</replaceable></arg>
|
<arg><option>--drv-link </option><replaceable>drvlink</replaceable></arg>
|
||||||
|
<arg><option>--add-drv-link</option></arg>
|
||||||
<arg><option>--no-out-link</option></arg>
|
<arg><option>--no-out-link</option></arg>
|
||||||
<arg>
|
<arg>
|
||||||
<group choice='req'>
|
<group choice='req'>
|
||||||
|
@ -83,26 +83,25 @@ except for <option>--arg</option> and <option>--attr</option> /
|
||||||
|
|
||||||
<variablelist>
|
<variablelist>
|
||||||
|
|
||||||
<varlistentry><term><option>--add-drv-link</option></term>
|
|
||||||
|
|
||||||
<listitem><para>Add a symlink in the current directory to the
|
|
||||||
store derivation produced by <command>nix-instantiate</command>.
|
|
||||||
The symlink is called <filename>derivation</filename> (which is
|
|
||||||
numbered in the case of multiple derivations). The derivation is
|
|
||||||
a root of the garbage collector until the symlink is deleted or
|
|
||||||
renamed.</para></listitem>
|
|
||||||
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
<varlistentry><term><option>--drv-link</option> <replaceable>drvlink</replaceable></term>
|
<varlistentry><term><option>--drv-link</option> <replaceable>drvlink</replaceable></term>
|
||||||
|
|
||||||
<listitem><para>Change the name of the symlink to the derivation
|
<listitem><para>Add a symlink named
|
||||||
created when <option>--add-drv-link</option> is used from
|
<replaceable>drvlink</replaceable> to the store derivation
|
||||||
<filename>derivation</filename> to
|
produced by <command>nix-instantiate</command>. The derivation is
|
||||||
<replaceable>drvlink</replaceable>.</para></listitem>
|
a root of the garbage collector until the symlink is deleted or
|
||||||
|
renamed. If there are multiple derivations, numbers are suffixed
|
||||||
|
to <replaceable>drvlink</replaceable> to distinguish between
|
||||||
|
them.</para></listitem>
|
||||||
|
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry><term><option>--add-drv-link</option></term>
|
||||||
|
|
||||||
|
<listitem><para>Shorthand for <option>--drv-link</option>
|
||||||
|
<filename>./derivation</filename>.</para></listitem>
|
||||||
|
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry><term><option>--no-out-link</option></term>
|
<varlistentry><term><option>--no-out-link</option></term>
|
||||||
|
|
||||||
<listitem><para>Do not create a symlink to the output path. Note
|
<listitem><para>Do not create a symlink to the output path. Note
|
||||||
|
@ -116,8 +115,7 @@ except for <option>--arg</option> and <option>--attr</option> /
|
||||||
<option>-o</option> <replaceable>outlink</replaceable></term>
|
<option>-o</option> <replaceable>outlink</replaceable></term>
|
||||||
|
|
||||||
<listitem><para>Change the name of the symlink to the output path
|
<listitem><para>Change the name of the symlink to the output path
|
||||||
created unless <option>--no-out-link</option> is used from
|
created from <filename>result</filename> to
|
||||||
<filename>result</filename> to
|
|
||||||
<replaceable>outlink</replaceable>.</para></listitem>
|
<replaceable>outlink</replaceable>.</para></listitem>
|
||||||
|
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
|
@ -2,14 +2,9 @@
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use Nix::Config;
|
use Nix::Config;
|
||||||
|
use File::Temp qw(tempdir);
|
||||||
|
|
||||||
|
|
||||||
my $addDrvLink = 0;
|
|
||||||
my $addOutLink = 1;
|
|
||||||
|
|
||||||
my $outLink;
|
|
||||||
my $drvLink;
|
|
||||||
|
|
||||||
my $dryRun = 0;
|
my $dryRun = 0;
|
||||||
my $verbose = 0;
|
my $verbose = 0;
|
||||||
|
|
||||||
|
@ -18,17 +13,14 @@ my @buildArgs = ();
|
||||||
my @exprs = ();
|
my @exprs = ();
|
||||||
|
|
||||||
|
|
||||||
END {
|
my $tmpDir = tempdir("nix-build.XXXXXX", CLEANUP => 1, TMPDIR => 1)
|
||||||
foreach my $fn (glob ".nix-build-tmp-*") {
|
or die "cannot create a temporary directory";
|
||||||
unlink $fn;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sub intHandler {
|
my $outLink = "./result";
|
||||||
exit 1;
|
my $drvLink = "$tmpDir/derivation";
|
||||||
}
|
|
||||||
|
|
||||||
$SIG{'INT'} = 'intHandler';
|
# Ensure that the $tmpDir is deleted.
|
||||||
|
$SIG{'INT'} = sub { exit 1 };
|
||||||
|
|
||||||
|
|
||||||
for (my $n = 0; $n < scalar @ARGV; $n++) {
|
for (my $n = 0; $n < scalar @ARGV; $n++) {
|
||||||
|
@ -56,11 +48,11 @@ EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
elsif ($arg eq "--add-drv-link") {
|
elsif ($arg eq "--add-drv-link") {
|
||||||
$addDrvLink = 1;
|
$drvLink = "./derivation";
|
||||||
}
|
}
|
||||||
|
|
||||||
elsif ($arg eq "--no-out-link" or $arg eq "--no-link") {
|
elsif ($arg eq "--no-out-link" or $arg eq "--no-link") {
|
||||||
$addOutLink = 0;
|
$outLink = "$tmpDir/result";
|
||||||
}
|
}
|
||||||
|
|
||||||
elsif ($arg eq "--drv-link") {
|
elsif ($arg eq "--drv-link") {
|
||||||
|
@ -139,17 +131,6 @@ EOF
|
||||||
@exprs = ("./default.nix") if scalar @exprs == 0;
|
@exprs = ("./default.nix") if scalar @exprs == 0;
|
||||||
|
|
||||||
|
|
||||||
if (!defined $drvLink) {
|
|
||||||
$drvLink = "derivation";
|
|
||||||
$drvLink = ".nix-build-tmp-" . $drvLink if !$addDrvLink;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!defined $outLink) {
|
|
||||||
$outLink = "result";
|
|
||||||
$outLink = ".nix-build-tmp-" . $outLink if !$addOutLink;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
foreach my $expr (@exprs) {
|
foreach my $expr (@exprs) {
|
||||||
|
|
||||||
# Instantiate.
|
# Instantiate.
|
||||||
|
|
Loading…
Reference in a new issue