about summary refs log tree commit diff
path: root/src/libstore/download.hh
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2019-06-17T06·43+0200
committerEelco Dolstra <edolstra@gmail.com>2019-06-24T20·07+0200
commit7b9c68766d513260d5262d5782b46384834cdb33 (patch)
tree85bdcc1602895a1fd72025ac3c36114f84af79d9 /src/libstore/download.hh
parent78fa47a7f08a4cb6ee7061bf0bd86a40e1d6dc91 (diff)
Add '--no-net' convenience flag
This flag

* Disables substituters.

* Sets the tarball-ttl to infinity (ensuring e.g. that the flake
  registry and any downloaded flakes are considered current).

* Disables retrying downloads and sets the connection timeout to the
  minimum. (So it doesn't completely disable downloads at the moment.)

(cherry picked from commit 8ea842260b4fd93315d35c5ba94b1ff99ab391d8)
Diffstat (limited to 'src/libstore/download.hh')
-rw-r--r--src/libstore/download.hh23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/libstore/download.hh b/src/libstore/download.hh
index 752f918575..dae082ab9a 100644
--- a/src/libstore/download.hh
+++ b/src/libstore/download.hh
@@ -9,13 +9,34 @@
 
 namespace nix {
 
+struct DownloadSettings : Config
+{
+    Setting<bool> enableHttp2{this, true, "http2",
+        "Whether to enable HTTP/2 support."};
+
+    Setting<std::string> userAgentSuffix{this, "", "user-agent-suffix",
+        "String appended to the user agent in HTTP requests."};
+
+    Setting<size_t> httpConnections{this, 25, "http-connections",
+        "Number of parallel HTTP connections.",
+        {"binary-caches-parallel-connections"}};
+
+    Setting<unsigned long> connectTimeout{this, 0, "connect-timeout",
+        "Timeout for connecting to servers during downloads. 0 means use curl's builtin default."};
+
+    Setting<unsigned int> tries{this, 5, "download-attempts",
+        "How often Nix will attempt to download a file before giving up."};
+};
+
+extern DownloadSettings downloadSettings;
+
 struct DownloadRequest
 {
     std::string uri;
     std::string expectedETag;
     bool verifyTLS = true;
     bool head = false;
-    size_t tries = 5;
+    size_t tries = downloadSettings.tries;
     unsigned int baseRetryTimeMs = 250;
     ActivityId parentAct;
     bool decompress = true;