about summary refs log tree commit diff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/nix-build.in7
-rwxr-xr-xscripts/nix-channel.in22
-rwxr-xr-xscripts/nix-collect-garbage.in7
-rwxr-xr-xscripts/nix-pull.in5
-rwxr-xr-xscripts/nix-push.in23
5 files changed, 26 insertions, 38 deletions
diff --git a/scripts/nix-build.in b/scripts/nix-build.in
index d9d1da73b12f..68c24b75d440 100755
--- a/scripts/nix-build.in
+++ b/scripts/nix-build.in
@@ -1,8 +1,7 @@
 #! @perl@ -w -I@libexecdir@/nix
 
 use strict;
-
-my $binDir = $ENV{"NIX_BIN_DIR"} || "@bindir@";
+use Nix::Config;
 
 
 my $addDrvLink = 0;
@@ -156,7 +155,7 @@ foreach my $expr (@exprs) {
     # Instantiate.
     my @drvPaths;
     # !!! 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, $_;}
     if (!close DRVPATHS) {
         die "nix-instantiate killed by signal " . ($? & 127) . "\n" if ($? & 127);
@@ -170,7 +169,7 @@ foreach my $expr (@exprs) {
 
     # Build.
     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;
     while (<OUTPATHS>) {chomp; push @outPaths, $_;}
     if (!close OUTPATHS) {
diff --git a/scripts/nix-channel.in b/scripts/nix-channel.in
index 3688063cba4e..9bfa04722647 100755
--- a/scripts/nix-channel.in
+++ b/scripts/nix-channel.in
@@ -1,15 +1,13 @@
 #! @perl@ -w
 
 use strict;
+use Nix::Config;
 
-my $rootsDir = "@localstatedir@/nix/gcroots";
-
-my $stateDir = $ENV{"NIX_STATE_DIR"};
-$stateDir = "@localstatedir@/nix" unless defined $stateDir;
+my $manifestDir = $Nix::Config::manifestDir;
 
 
 # Turn on caching in nix-prefetch-url.
-my $channelCache = "$stateDir/channel-cache";
+my $channelCache = "$Nix::Config::stateDir/channel-cache";
 mkdir $channelCache, 0755 unless -e $channelCache;
 $ENV{'NIX_DOWNLOAD_CACHE'} = $channelCache if -W $channelCache;
 
@@ -79,19 +77,19 @@ sub update {
     readChannels;
 
     # Create the manifests directory if it doesn't exist.
-    mkdir "$stateDir/manifests", 0755 unless -e "$stateDir/manifests";
+    mkdir $manifestDir, 0755 unless -e $manifestDir;
 
     # Do we have write permission to the manifests directory?  If not,
     # then just skip pulling the manifest and just download the Nix
     # expressions.  If the user is a non-privileged user in a
     # multi-user Nix installation, he at least gets installation from
     # source.
-    if (-W "$stateDir/manifests") {
+    if (-W $manifestDir) {
 
         # Pull cache manifests.
         foreach my $url (@channels) {
             #print "pulling cache manifest from `$url'\n";
-            system("@bindir@/nix-pull", "--skip-wrong-store", "$url/MANIFEST") == 0
+            system("$Nix::Config::binDir/nix-pull", "--skip-wrong-store", "$url/MANIFEST") == 0
                 or die "cannot pull cache manifest from `$url'";
         }
 
@@ -110,7 +108,7 @@ sub update {
         print "downloading Nix expressions from `$fullURL'...\n";
         $ENV{"PRINT_PATH"} = 1;
         $ENV{"QUIET"} = 1;
-        my ($hash, $path) = `@bindir@/nix-prefetch-url '$fullURL'`;
+        my ($hash, $path) = `$Nix::Config::binDir/nix-prefetch-url '$fullURL'`;
         die "cannot fetch `$fullURL'" if $? != 0;
         chomp $path;
         $inputs .= '"' . $channelName . '"' . " " . $path . " ";
@@ -121,13 +119,13 @@ sub update {
     my $userName = getpwuid($<);
     die "who ARE you? go away" unless defined $userName;
 
-    my $rootFile = "$rootsDir/per-user/$userName/channels";
+    my $rootFile = "$Nix::Config::stateDir/gcroots/per-user/$userName/channels";
     
     # Build the Nix expression.
     print "unpacking channel Nix expressions...\n";
     my $outPath = `\\
-        @bindir@/nix-build --out-link '$rootFile' --drv-link '$rootFile'.tmp \\
-        @datadir@/nix/corepkgs/channels/unpack.nix \\
+        $Nix::Config::binDir/nix-build --out-link '$rootFile' --drv-link '$rootFile'.tmp \\
+        '<nix/unpack-channel.nix>' \\
         --argstr system @system@ --arg inputs '$inputs'`
         or die "cannot unpack the channels";
     chomp $outPath;
diff --git a/scripts/nix-collect-garbage.in b/scripts/nix-collect-garbage.in
index f445c1c71256..00e61a24b785 100755
--- a/scripts/nix-collect-garbage.in
+++ b/scripts/nix-collect-garbage.in
@@ -1,11 +1,10 @@
 #! @perl@ -w
 
 use strict;
+use Nix::Config;
 
 my $profilesDir = "@localstatedir@/nix/profiles";
 
-my $binDir = $ENV{"NIX_BIN_DIR"} || "@bindir@";
-
 
 # Process the command line arguments.
 my @args = ();
@@ -36,7 +35,7 @@ sub removeOldGenerations {
         $name = $dir . "/" . $name;
         if (-l $name && (readlink($name) =~ /link/)) {
             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) {
             removeOldGenerations $name;
@@ -50,4 +49,4 @@ removeOldGenerations $profilesDir if $removeOld;
 
 
 # Run the actual garbage collector.
-exec "$binDir/nix-store", "--gc", @args;
+exec "$Nix::Config::binDir/nix-store", "--gc", @args;
diff --git a/scripts/nix-pull.in b/scripts/nix-pull.in
index 74545a35004c..136a5c9fa4bd 100755
--- a/scripts/nix-pull.in
+++ b/scripts/nix-pull.in
@@ -8,9 +8,6 @@ use Nix::Manifest;
 my $tmpDir = tempdir("nix-pull.XXXXXX", CLEANUP => 1, TMPDIR => 1)
     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;
 
 
@@ -25,7 +22,7 @@ if (! -e $manifestDir) {
 
 
 # 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";
 if (! -l $manifestDirLink) {
     symlink($manifestDir, $manifestDirLink) or die "cannot create symlink `$manifestDirLink'";
diff --git a/scripts/nix-push.in b/scripts/nix-push.in
index cf46d00dfb06..1e0918abd6ac 100755
--- a/scripts/nix-push.in
+++ b/scripts/nix-push.in
@@ -18,11 +18,6 @@ my $curl = "$Nix::Config::curl --fail --silent";
 my $extraCurlFlags = ${ENV{'CURL_FLAGS'}};
 $curl = "$curl $extraCurlFlags" if defined $extraCurlFlags;
 
-my $binDir = $ENV{"NIX_BIN_DIR"} || "@bindir@";
-
-my $dataDir = $ENV{"NIX_DATA_DIR"};
-$dataDir = "@datadir@" unless defined $dataDir;
-
 
 # Parse the command line.
 my $localCopy;
@@ -82,7 +77,7 @@ foreach my $path (@ARGV) {
     # Get all paths referenced by the normalisation of the given 
     # Nix expression.
     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;
     
     while (<READ>) {
@@ -107,7 +102,7 @@ foreach my $storePath (@storePaths) {
 
     # Construct a Nix expression that creates a Nix archive.
     my $nixexpr = 
-        "((import $dataDir/nix/corepkgs/nar/nar.nix) " .
+        "(import <nix/nar.nix> " .
         "{ storePath = builtins.storePath \"$storePath\"; system = \"@system@\"; hashAlgo = \"$hashAlgo\"; }) ";
     
     print NIX $nixexpr;
@@ -120,7 +115,7 @@ close NIX;
 # Instantiate store derivations from the Nix expression.
 my @storeExprs;
 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";
 while (<READ>) {
     chomp;
@@ -142,7 +137,7 @@ while (scalar @tmp > 0) {
     my @tmp2 = @tmp[0..$n - 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";
     while (<READ>) {
         chomp;
@@ -182,16 +177,16 @@ for (my $n = 0; $n < scalar @storePaths; $n++) {
 
     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;
     $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;
     chomp $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;
     chomp $narHash;
 
@@ -199,13 +194,13 @@ for (my $n = 0; $n < scalar @storePaths; $n++) {
     # store of the host), the database doesn't contain the hash.  So
     # compute it.
     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;
         chomp $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;
     chomp $narSize;