aboutsummaryrefslogtreecommitdiff
path: root/src/libstore
diff options
context:
space:
mode:
authorSolene Rapenne <solene@perso.pw>2022-08-19 12:40:22 +0200
committerSolene Rapenne <solene@perso.pw>2022-08-19 12:40:22 +0200
commit0d2bf7acf994ba331d6f72c746721b354931be76 (patch)
treefaa4739dde482c9d14c5cb1e700898e56b76c5cc /src/libstore
parent7aa36ae79673d89e120a97a3c6fd9fbb46ea9da1 (diff)
add a nix.conf option to set a download speed limit
Diffstat (limited to 'src/libstore')
-rw-r--r--src/libstore/filetransfer.cc3
-rw-r--r--src/libstore/globals.hh7
2 files changed, 10 insertions, 0 deletions
diff --git a/src/libstore/filetransfer.cc b/src/libstore/filetransfer.cc
index 8454ad7d2..252403cb5 100644
--- a/src/libstore/filetransfer.cc
+++ b/src/libstore/filetransfer.cc
@@ -308,6 +308,9 @@ struct curlFileTransfer : public FileTransfer
curl_easy_setopt(req, CURLOPT_HTTPHEADER, requestHeaders);
+ if (settings.downloadSpeed.get() > 0)
+ curl_easy_setopt(req, CURLOPT_MAX_RECV_SPEED_LARGE, (curl_off_t) (settings.downloadSpeed.get() * 1024));
+
if (request.head)
curl_easy_setopt(req, CURLOPT_NOBODY, 1);
diff --git a/src/libstore/globals.hh b/src/libstore/globals.hh
index d7f351166..ca8fc6d5f 100644
--- a/src/libstore/globals.hh
+++ b/src/libstore/globals.hh
@@ -746,6 +746,13 @@ public:
/nix/store/xfghy8ixrhz3kyy6p724iv3cxji088dx-bash-4.4-p23`.
)"};
+ Setting<unsigned int> downloadSpeed {
+ this, 0, "download-speed",
+ R"(
+ Specify the maxium transfer rate in kilobytes per second you want
+ nix to use for download.
+ )"};
+
Setting<std::string> netrcFile{
this, fmt("%s/%s", nixConfDir, "netrc"), "netrc-file",
R"(