diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2022-08-22 14:57:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-22 14:57:19 +0200 |
commit | 8d84634e26d6a09f9ca3fe71fcf9cba6e4a95107 (patch) | |
tree | b33cbb02620d79004fb826db6bcea7f733fe49ed /src | |
parent | 590660c1c6cb664df8a89053f4d8b069933c6189 (diff) | |
parent | c21b1a7e67cc28b6e95a563daa786f385bc716b8 (diff) |
Merge pull request #6926 from rapenne-s/download_limit
add a nix.conf option to set a download speed limit
Diffstat (limited to 'src')
-rw-r--r-- | src/libstore/filetransfer.cc | 3 | ||||
-rw-r--r-- | src/libstore/globals.hh | 7 |
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..e9d721e59 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 maximum transfer rate in kilobytes per second you want + Nix to use for downloads. + )"}; + Setting<std::string> netrcFile{ this, fmt("%s/%s", nixConfDir, "netrc"), "netrc-file", R"( |