* nix-pack-closure: store the top-level store paths in the closure.
* nix-unpack-closure: extract the top-level paths from the closure and print them on stdout. This allows them to be installed, e.g., "nix-env -i $(nix-unpack-closure)". (NIX-64)
This commit is contained in:
parent
f25f900045
commit
afe23b5f38
|
@ -58,6 +58,14 @@ $ nix-pack-closure $(which azureus) | ssh scratchy nix-unpack-closure</screen>
|
|||
|
||||
</para>
|
||||
|
||||
<para>As a variation on the previous example, copy
|
||||
<command>azureus</command>, and also install it in the user’s profile
|
||||
on the target machine:
|
||||
|
||||
<screen>
|
||||
$ nix-pack-closure $(which azureus) | ssh scratchy 'nix-env -i $(nix-unpack-closure)'</screen>
|
||||
|
||||
|
||||
</refsection>
|
||||
|
||||
|
||||
|
|
|
@ -22,6 +22,12 @@ closure is a single file read from standard input. See the
|
|||
description of <command>nix-pack-closure</command> for details and
|
||||
examples.</para>
|
||||
|
||||
<para>The top-level paths in the closure (i.e., the paths passed to
|
||||
the original <command>nix-pack-closure</command> call that created the
|
||||
closure) are printed on standard output. These paths can be passed,
|
||||
for instance, to <literal>nix-env -i</literal> to install them into a
|
||||
user environment on the target machine.</para>
|
||||
|
||||
</refsection>
|
||||
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ mkdir "$tmpDir/contents", 0777 or die;
|
|||
mkdir "$tmpDir/references", 0777 or die;
|
||||
mkdir "$tmpDir/derivers", 0777 or die;
|
||||
|
||||
open TOPLEVEL, ">$tmpDir/top-level" or die;
|
||||
|
||||
|
||||
my %storePaths;
|
||||
|
@ -29,6 +30,12 @@ my %storePaths;
|
|||
while (@ARGV) {
|
||||
my $storePath = shift @ARGV;
|
||||
|
||||
# $storePath might be a symlink to the store, so resolve it.
|
||||
$storePath = (`$binDir/nix-store --query --resolve '$storePath'`
|
||||
or die "cannot resolve `$storePath'");
|
||||
chomp $storePath;
|
||||
print TOPLEVEL $storePath, "\n";
|
||||
|
||||
# Get the closure of this path.
|
||||
my $pid = open(READ,
|
||||
"$binDir/nix-store --query --requisites '$storePath'|") or die;
|
||||
|
|
|
@ -77,3 +77,12 @@ closedir(DIR) or die;
|
|||
# Register the invalid paths as valid.
|
||||
system("nix-store --register-validity <'$tmpDir/validity'") == 0
|
||||
or die "nix-store --register-validity failed";
|
||||
|
||||
|
||||
# Show the top-level paths so that something useful can be done with
|
||||
# them, e.g., passing them to `nix-env -i'.
|
||||
if (-e "$tmpDir/unpacked/top-level") {
|
||||
open TOPLEVEL, "<$tmpDir/unpacked/top-level" or die;
|
||||
while (<TOPLEVEL>) { print "$_"; }
|
||||
close TOPLEVEL;
|
||||
}
|
||||
|
|
|
@ -296,7 +296,7 @@ static void opQuery(Strings opFlags, Strings opArgs)
|
|||
{
|
||||
enum { qOutputs, qRequisites, qReferences, qReferrers
|
||||
, qReferrersClosure, qDeriver, qBinding, qHash
|
||||
, qTree, qGraph } query = qOutputs;
|
||||
, qTree, qGraph, qResolve } query = qOutputs;
|
||||
bool useOutput = false;
|
||||
bool includeOutputs = false;
|
||||
bool forceRealise = false;
|
||||
|
@ -320,6 +320,7 @@ static void opQuery(Strings opFlags, Strings opArgs)
|
|||
else if (*i == "--hash") query = qHash;
|
||||
else if (*i == "--tree") query = qTree;
|
||||
else if (*i == "--graph") query = qGraph;
|
||||
else if (*i == "--resolve") query = qResolve;
|
||||
else if (*i == "--use-output" || *i == "-u") useOutput = true;
|
||||
else if (*i == "--force-realise" || *i == "-f") forceRealise = true;
|
||||
else if (*i == "--include-outputs") includeOutputs = true;
|
||||
|
@ -410,6 +411,13 @@ static void opQuery(Strings opFlags, Strings opArgs)
|
|||
break;
|
||||
}
|
||||
|
||||
case qResolve: {
|
||||
for (Strings::iterator i = opArgs.begin();
|
||||
i != opArgs.end(); ++i)
|
||||
cout << format("%1%\n") % fixPath(*i);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue