* Use Nix::Config.
This commit is contained in:
parent
48cea0d01e
commit
dadbb51d96
4 changed files with 15 additions and 22 deletions
|
@ -1,8 +1,7 @@
|
||||||
#! @perl@ -w -I@libexecdir@/nix
|
#! @perl@ -w -I@libexecdir@/nix
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
|
use Nix::Config;
|
||||||
my $binDir = $ENV{"NIX_BIN_DIR"} || "@bindir@";
|
|
||||||
|
|
||||||
|
|
||||||
my $addDrvLink = 0;
|
my $addDrvLink = 0;
|
||||||
|
@ -156,7 +155,7 @@ foreach my $expr (@exprs) {
|
||||||
# Instantiate.
|
# Instantiate.
|
||||||
my @drvPaths;
|
my @drvPaths;
|
||||||
# !!! would prefer the perl 5.8.0 pipe open feature here.
|
# !!! would prefer the perl 5.8.0 pipe open feature here.
|
||||||
my $pid = open(DRVPATHS, "-|") || exec "$binDir/nix-instantiate", "--add-root", $drvLink, "--indirect", @instArgs, $expr;
|
my $pid = open(DRVPATHS, "-|") || exec "$Nix::Config::binDir/nix-instantiate", "--add-root", $drvLink, "--indirect", @instArgs, $expr;
|
||||||
while (<DRVPATHS>) {chomp; push @drvPaths, $_;}
|
while (<DRVPATHS>) {chomp; push @drvPaths, $_;}
|
||||||
if (!close DRVPATHS) {
|
if (!close DRVPATHS) {
|
||||||
die "nix-instantiate killed by signal " . ($? & 127) . "\n" if ($? & 127);
|
die "nix-instantiate killed by signal " . ($? & 127) . "\n" if ($? & 127);
|
||||||
|
@ -170,7 +169,7 @@ foreach my $expr (@exprs) {
|
||||||
|
|
||||||
# Build.
|
# Build.
|
||||||
my @outPaths;
|
my @outPaths;
|
||||||
$pid = open(OUTPATHS, "-|") || exec "$binDir/nix-store", "--add-root", $outLink, "--indirect", "-r",
|
$pid = open(OUTPATHS, "-|") || exec "$Nix::Config::binDir/nix-store", "--add-root", $outLink, "--indirect", "-r",
|
||||||
@buildArgs, @drvPaths;
|
@buildArgs, @drvPaths;
|
||||||
while (<OUTPATHS>) {chomp; push @outPaths, $_;}
|
while (<OUTPATHS>) {chomp; push @outPaths, $_;}
|
||||||
if (!close OUTPATHS) {
|
if (!close OUTPATHS) {
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
#! @perl@ -w
|
#! @perl@ -w
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
|
use Nix::Config;
|
||||||
|
|
||||||
my $profilesDir = "@localstatedir@/nix/profiles";
|
my $profilesDir = "@localstatedir@/nix/profiles";
|
||||||
|
|
||||||
my $binDir = $ENV{"NIX_BIN_DIR"} || "@bindir@";
|
|
||||||
|
|
||||||
|
|
||||||
# Process the command line arguments.
|
# Process the command line arguments.
|
||||||
my @args = ();
|
my @args = ();
|
||||||
|
@ -36,7 +35,7 @@ sub removeOldGenerations {
|
||||||
$name = $dir . "/" . $name;
|
$name = $dir . "/" . $name;
|
||||||
if (-l $name && (readlink($name) =~ /link/)) {
|
if (-l $name && (readlink($name) =~ /link/)) {
|
||||||
print STDERR "removing old generations of profile $name\n";
|
print STDERR "removing old generations of profile $name\n";
|
||||||
system("$binDir/nix-env", "-p", $name, "--delete-generations", "old");
|
system("$Nix::Config::binDir/nix-env", "-p", $name, "--delete-generations", "old");
|
||||||
}
|
}
|
||||||
elsif (! -l $name && -d $name) {
|
elsif (! -l $name && -d $name) {
|
||||||
removeOldGenerations $name;
|
removeOldGenerations $name;
|
||||||
|
@ -50,4 +49,4 @@ removeOldGenerations $profilesDir if $removeOld;
|
||||||
|
|
||||||
|
|
||||||
# Run the actual garbage collector.
|
# Run the actual garbage collector.
|
||||||
exec "$binDir/nix-store", "--gc", @args;
|
exec "$Nix::Config::binDir/nix-store", "--gc", @args;
|
||||||
|
|
|
@ -8,9 +8,6 @@ use Nix::Manifest;
|
||||||
my $tmpDir = tempdir("nix-pull.XXXXXX", CLEANUP => 1, TMPDIR => 1)
|
my $tmpDir = tempdir("nix-pull.XXXXXX", CLEANUP => 1, TMPDIR => 1)
|
||||||
or die "cannot create a temporary directory";
|
or die "cannot create a temporary directory";
|
||||||
|
|
||||||
my $libexecDir = ($ENV{"NIX_LIBEXEC_DIR"} or "@libexecdir@");
|
|
||||||
my $storeDir = ($ENV{"NIX_STORE_DIR"} or "@storedir@");
|
|
||||||
my $stateDir = ($ENV{"NIX_STATE_DIR"} or "@localstatedir@/nix");
|
|
||||||
my $manifestDir = $Nix::Config::manifestDir;
|
my $manifestDir = $Nix::Config::manifestDir;
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,7 +22,7 @@ if (! -e $manifestDir) {
|
||||||
|
|
||||||
|
|
||||||
# Make sure that the manifests directory is scanned for GC roots.
|
# Make sure that the manifests directory is scanned for GC roots.
|
||||||
my $gcRootsDir = "$stateDir/gcroots";
|
my $gcRootsDir = "$Nix::Config::stateDir/gcroots";
|
||||||
my $manifestDirLink = "$gcRootsDir/manifests";
|
my $manifestDirLink = "$gcRootsDir/manifests";
|
||||||
if (! -l $manifestDirLink) {
|
if (! -l $manifestDirLink) {
|
||||||
symlink($manifestDir, $manifestDirLink) or die "cannot create symlink `$manifestDirLink'";
|
symlink($manifestDir, $manifestDirLink) or die "cannot create symlink `$manifestDirLink'";
|
||||||
|
|
|
@ -18,8 +18,6 @@ my $curl = "$Nix::Config::curl --fail --silent";
|
||||||
my $extraCurlFlags = ${ENV{'CURL_FLAGS'}};
|
my $extraCurlFlags = ${ENV{'CURL_FLAGS'}};
|
||||||
$curl = "$curl $extraCurlFlags" if defined $extraCurlFlags;
|
$curl = "$curl $extraCurlFlags" if defined $extraCurlFlags;
|
||||||
|
|
||||||
my $binDir = $ENV{"NIX_BIN_DIR"} || "@bindir@";
|
|
||||||
|
|
||||||
|
|
||||||
# Parse the command line.
|
# Parse the command line.
|
||||||
my $localCopy;
|
my $localCopy;
|
||||||
|
@ -79,7 +77,7 @@ foreach my $path (@ARGV) {
|
||||||
# Get all paths referenced by the normalisation of the given
|
# Get all paths referenced by the normalisation of the given
|
||||||
# Nix expression.
|
# Nix expression.
|
||||||
my $pid = open(READ,
|
my $pid = open(READ,
|
||||||
"$binDir/nix-store --query --requisites --force-realise " .
|
"$Nix::Config::binDir/nix-store --query --requisites --force-realise " .
|
||||||
"--include-outputs '$path'|") or die;
|
"--include-outputs '$path'|") or die;
|
||||||
|
|
||||||
while (<READ>) {
|
while (<READ>) {
|
||||||
|
@ -117,7 +115,7 @@ close NIX;
|
||||||
# Instantiate store derivations from the Nix expression.
|
# Instantiate store derivations from the Nix expression.
|
||||||
my @storeExprs;
|
my @storeExprs;
|
||||||
print STDERR "instantiating store derivations...\n";
|
print STDERR "instantiating store derivations...\n";
|
||||||
my $pid = open(READ, "$binDir/nix-instantiate $nixExpr|")
|
my $pid = open(READ, "$Nix::Config::binDir/nix-instantiate $nixExpr|")
|
||||||
or die "cannot run nix-instantiate";
|
or die "cannot run nix-instantiate";
|
||||||
while (<READ>) {
|
while (<READ>) {
|
||||||
chomp;
|
chomp;
|
||||||
|
@ -139,7 +137,7 @@ while (scalar @tmp > 0) {
|
||||||
my @tmp2 = @tmp[0..$n - 1];
|
my @tmp2 = @tmp[0..$n - 1];
|
||||||
@tmp = @tmp[$n..scalar @tmp - 1];
|
@tmp = @tmp[$n..scalar @tmp - 1];
|
||||||
|
|
||||||
my $pid = open(READ, "$binDir/nix-store --realise @tmp2|")
|
my $pid = open(READ, "$Nix::Config::binDir/nix-store --realise @tmp2|")
|
||||||
or die "cannot run nix-store";
|
or die "cannot run nix-store";
|
||||||
while (<READ>) {
|
while (<READ>) {
|
||||||
chomp;
|
chomp;
|
||||||
|
@ -179,16 +177,16 @@ for (my $n = 0; $n < scalar @storePaths; $n++) {
|
||||||
|
|
||||||
my $narbz2Size = stat($narFile)->size;
|
my $narbz2Size = stat($narFile)->size;
|
||||||
|
|
||||||
my $references = `$binDir/nix-store --query --references '$storePath'`;
|
my $references = `$Nix::Config::binDir/nix-store --query --references '$storePath'`;
|
||||||
die "cannot query references for `$storePath'" if $? != 0;
|
die "cannot query references for `$storePath'" if $? != 0;
|
||||||
$references = join(" ", split(" ", $references));
|
$references = join(" ", split(" ", $references));
|
||||||
|
|
||||||
my $deriver = `$binDir/nix-store --query --deriver '$storePath'`;
|
my $deriver = `$Nix::Config::binDir/nix-store --query --deriver '$storePath'`;
|
||||||
die "cannot query deriver for `$storePath'" if $? != 0;
|
die "cannot query deriver for `$storePath'" if $? != 0;
|
||||||
chomp $deriver;
|
chomp $deriver;
|
||||||
$deriver = "" if $deriver eq "unknown-deriver";
|
$deriver = "" if $deriver eq "unknown-deriver";
|
||||||
|
|
||||||
my $narHash = `$binDir/nix-store --query --hash '$storePath'`;
|
my $narHash = `$Nix::Config::binDir/nix-store --query --hash '$storePath'`;
|
||||||
die "cannot query hash for `$storePath'" if $? != 0;
|
die "cannot query hash for `$storePath'" if $? != 0;
|
||||||
chomp $narHash;
|
chomp $narHash;
|
||||||
|
|
||||||
|
@ -196,13 +194,13 @@ for (my $n = 0; $n < scalar @storePaths; $n++) {
|
||||||
# store of the host), the database doesn't contain the hash. So
|
# store of the host), the database doesn't contain the hash. So
|
||||||
# compute it.
|
# compute it.
|
||||||
if ($narHash =~ /^sha256:0*$/) {
|
if ($narHash =~ /^sha256:0*$/) {
|
||||||
$narHash = `$binDir/nix-hash --type sha256 --base32 '$storePath'`;
|
$narHash = `$Nix::Config::binDir/nix-hash --type sha256 --base32 '$storePath'`;
|
||||||
die "cannot hash `$storePath'" if $? != 0;
|
die "cannot hash `$storePath'" if $? != 0;
|
||||||
chomp $narHash;
|
chomp $narHash;
|
||||||
$narHash = "sha256:$narHash";
|
$narHash = "sha256:$narHash";
|
||||||
}
|
}
|
||||||
|
|
||||||
my $narSize = `$binDir/nix-store --query --size '$storePath'`;
|
my $narSize = `$Nix::Config::binDir/nix-store --query --size '$storePath'`;
|
||||||
die "cannot query size for `$storePath'" if $? != 0;
|
die "cannot query size for `$storePath'" if $? != 0;
|
||||||
chomp $narSize;
|
chomp $narSize;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue