diff --git a/src/nix/main.cc b/src/nix/main.cc index eb510eecc..f05c49523 100644 --- a/src/nix/main.cc +++ b/src/nix/main.cc @@ -27,6 +27,24 @@ void chrootHelper(int argc, char * * argv); namespace nix { +static bool haveProxyEnvironmentVariables() +{ + static const std::vector proxyVariables = { + "http_proxy", + "https_proxy", + "ftp_proxy", + "HTTP_PROXY", + "HTTPS_PROXY", + "FTP_PROXY" + }; + for (auto & proxyVariable: proxyVariables) { + if (getEnv(proxyVariable).has_value()) { + return true; + } + } + return false; +} + /* Check if we have a non-loopback/link-local network interface. */ static bool haveInternet() { @@ -50,6 +68,8 @@ static bool haveInternet() } } + if (haveProxyEnvironmentVariables()) return true; + return false; }