diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2012-01-03 01:51:38 +0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2012-01-03 01:51:38 +0000 |
commit | 39d45a6b090b5105423b22b8ef39c2a4a000a4a1 (patch) | |
tree | 945e102b1f482f8eb393fe1c597b8ea499b26bf3 /scripts | |
parent | dadbb51d969517c1f2512015ab201dc99088d9a6 (diff) | |
download | guix-39d45a6b090b5105423b22b8ef39c2a4a000a4a1.tar.gz |
* Add a test for nix-channel.
* Refactor the nix-channel unpacker a bit.
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/nix-channel.in | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/scripts/nix-channel.in b/scripts/nix-channel.in index 3688063cba..9bfa047226 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; |