diff options
Diffstat (limited to 'scripts/nix-install-package.in')
-rwxr-xr-x | scripts/nix-install-package.in | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/scripts/nix-install-package.in b/scripts/nix-install-package.in index 951c2918fa70..6564529385d6 100755 --- a/scripts/nix-install-package.in +++ b/scripts/nix-install-package.in @@ -3,6 +3,7 @@ use strict; use File::Temp qw(tempdir); use Nix::Config; +use Nix::Utils; sub usageError { @@ -72,7 +73,7 @@ my $tmpDir = tempdir("nix-install-package.XXXXXX", CLEANUP => 1, TMPDIR => 1) sub barf { my $msg = shift; - print "$msg\n"; + print "\nInstallation failed: $msg\n"; <STDIN> if $interactive; exit 1; } @@ -92,7 +93,6 @@ open PKGFILE, "<$pkgFile" or barf "cannot open `$pkgFile': $!"; my $contents = <PKGFILE>; close PKGFILE; -my $urlRE = "(?: [a-zA-Z][a-zA-Z0-9\+\-\.]*\:[a-zA-Z0-9\%\/\?\:\@\&\=\+\$\,\-\_\.\!\~\*\']+ )"; my $nameRE = "(?: [A-Za-z0-9\+\-\.\_\?\=]+ )"; # see checkStoreName() my $systemRE = "(?: [A-Za-z0-9\+\-\_]+ )"; my $pathRE = "(?: \/ [\/A-Za-z0-9\+\-\.\_\?\=]* )"; @@ -101,7 +101,7 @@ my $pathRE = "(?: \/ [\/A-Za-z0-9\+\-\.\_\?\=]* )"; # store path. We'll let nix-env do that. $contents =~ - / ^ \s* (\S+) \s+ ($urlRE) \s+ ($nameRE) \s+ ($systemRE) \s+ ($pathRE) \s+ ($pathRE) /x + / ^ \s* (\S+) \s+ ($Nix::Utils::urlRE) \s+ ($nameRE) \s+ ($systemRE) \s+ ($pathRE) \s+ ($pathRE) ( \s+ ($Nix::Utils::urlRE) )? /x or barf "invalid package contents"; my $version = $1; my $manifestURL = $2; @@ -109,6 +109,7 @@ my $drvName = $3; my $system = $4; my $drvPath = $5; my $outPath = $6; +my $binaryCacheURL = $8; barf "invalid package version `$version'" unless $version eq "NIXPKG1"; @@ -122,17 +123,25 @@ if ($interactive) { } -# Store the manifest in the temporary directory so that we don't -# pollute /nix/var/nix/manifests. This also requires that we don't -# use the Nix daemon (because otherwise download-using-manifests won't -# see our NIX_MANIFESTS_DIRS environment variable). -$ENV{NIX_MANIFESTS_DIR} = $tmpDir; -$ENV{NIX_REMOTE} = ""; +if (defined $binaryCacheURL) { + push @extraNixEnvArgs, "--option", "binary-caches", $binaryCacheURL; -print "\nPulling manifests...\n"; -system("$Nix::Config::binDir/nix-pull", $manifestURL) == 0 - or barf "nix-pull failed: $?"; +} else { + + # Store the manifest in the temporary directory so that we don't + # pollute /nix/var/nix/manifests. This also requires that we + # don't use the Nix daemon (because otherwise + # download-using-manifests won't see our NIX_MANIFESTS_DIRS + # environment variable). + $ENV{NIX_MANIFESTS_DIR} = $tmpDir; + $ENV{NIX_REMOTE} = ""; + + print "\nPulling manifests...\n"; + system("$Nix::Config::binDir/nix-pull", $manifestURL) == 0 + or barf "nix-pull failed: $?"; + +} print "\nInstalling package...\n"; |