diff options
-rw-r--r-- | doc/manual/conf-file.xml | 20 | ||||
-rw-r--r-- | perl/lib/Nix/Config.pm.in | 6 | ||||
-rw-r--r-- | scripts/download-from-binary-cache.pl.in | 10 |
3 files changed, 30 insertions, 6 deletions
diff --git a/doc/manual/conf-file.xml b/doc/manual/conf-file.xml index 25a009de9d45..e2890b1031ed 100644 --- a/doc/manual/conf-file.xml +++ b/doc/manual/conf-file.xml @@ -288,6 +288,26 @@ build-use-chroot = /dev /proc /bin</programlisting> </varlistentry> + <varlistentry><term><literal>binary-caches</literal></term> + + <listitem><para>A list of URLs of binary caches, separated by + whitespace. It can be overriden through the environment variable + <envar>NIX_BINARY_CACHES</envar>. The default is + <literal>http://nixos.org/binary-cache</literal>.</para></listitem> + + </varlistentry> + + + <varlistentry><term><literal>binary-caches-parallel-connections</literal></term> + + <listitem><para>The maximum number of parallel HTTP connections + used by the binary cache substituter to get NAR info files. This + number should be high to minimise latency. It defaults to + 150.</para></listitem> + + </varlistentry> + + <varlistentry><term><literal>system</literal></term> <listitem><para>This option specifies the canonical Nix system diff --git a/perl/lib/Nix/Config.pm.in b/perl/lib/Nix/Config.pm.in index 64aaccd7cd31..57751b6b4057 100644 --- a/perl/lib/Nix/Config.pm.in +++ b/perl/lib/Nix/Config.pm.in @@ -14,16 +14,16 @@ $curl = "@curl@"; $useBindings = "@perlbindings@" eq "yes"; +%config = (); + sub readConfig { - my %config; - my $config = "@sysconfdir@/nix/nix.conf"; + my $config = "$confDir/nix.conf"; return unless -f $config; open CONFIG, "<$config" or die "cannot open `$config'"; while (<CONFIG>) { /^\s*([\w|-]+)\s*=\s*(.*)$/ or next; $config{$1} = $2; - print "|$1| -> |$2|\n"; } close CONFIG; } diff --git a/scripts/download-from-binary-cache.pl.in b/scripts/download-from-binary-cache.pl.in index 37f8db0a9905..f062d17e6e94 100644 --- a/scripts/download-from-binary-cache.pl.in +++ b/scripts/download-from-binary-cache.pl.in @@ -10,9 +10,13 @@ use WWW::Curl::Multi; use strict; -my @binaryCacheUrls = map { s/\/+$//; $_ } split(/ /, ($ENV{"NIX_BINARY_CACHES"} || "")); +Nix::Config::readConfig; -my $maxParallelRequests = 150; +my @binaryCacheUrls = map { s/\/+$//; $_ } split(/ /, + ($ENV{"NIX_BINARY_CACHES"} // $Nix::Config::config{"binary-caches"} // "http://nixos.org/binary-cache")); + +my $maxParallelRequests = int($Nix::Config::config{"binary-caches-parallel-connections"} // 150); +$maxParallelRequests = 1 if $maxParallelRequests < 1; my ($dbh, $insertNAR, $queryNAR, $insertNegativeNAR, $queryNegativeNAR); my %cacheIds; @@ -22,7 +26,7 @@ my $activeRequests = 0; my $curlIdCount = 1; my %requests; my %scheduled; -my $caBundle = $ENV{"CURL_CA_BUNDLE"} || $ENV{"OPENSSL_X509_CERT_FILE"}; +my $caBundle = $ENV{"CURL_CA_BUNDLE"} // $ENV{"OPENSSL_X509_CERT_FILE"}; sub addRequest { |