diff --git a/lib/fetchers.nix b/lib/fetchers.nix index e94c611299be..b2fe7872a12b 100644 --- a/lib/fetchers.nix +++ b/lib/fetchers.nix @@ -9,6 +9,9 @@ # by definition pure. "http_proxy" "https_proxy" "ftp_proxy" "all_proxy" "no_proxy" "HTTP_PROXY" "HTTPS_PROXY" "FTP_PROXY" "ALL_PROXY" "NO_PROXY" + + # https proxies typically need to inject custom root CAs too + "NIX_SSL_CERT_FILE" ]; } diff --git a/pkgs/build-support/fetchgit/default.nix b/pkgs/build-support/fetchgit/default.nix index 66bb3b7c09ff..92c7468753e8 100644 --- a/pkgs/build-support/fetchgit/default.nix +++ b/pkgs/build-support/fetchgit/default.nix @@ -67,7 +67,7 @@ stdenvNoCC.mkDerivation { builder = ./builder.sh; fetcher = ./nix-prefetch-git; - nativeBuildInputs = [ git ] + nativeBuildInputs = [ git cacert ] ++ lib.optionals fetchLFS [ git-lfs ]; outputHashAlgo = if hash != "" then null else "sha256"; @@ -94,8 +94,6 @@ stdenvNoCC.mkDerivation { export HOME=$PWD ''; - GIT_SSL_CAINFO = "${cacert}/etc/ssl/certs/ca-bundle.crt"; - impureEnvVars = lib.fetchers.proxyImpureEnvVars ++ netrcImpureEnvVars ++ [ "GIT_PROXY_COMMAND" "NIX_GIT_SSL_CAINFO" "SOCKS_SERVER" ]; diff --git a/pkgs/build-support/fetchgit/nix-prefetch-git b/pkgs/build-support/fetchgit/nix-prefetch-git index 0f41cbd6a265..b921f161f012 100755 --- a/pkgs/build-support/fetchgit/nix-prefetch-git +++ b/pkgs/build-support/fetchgit/nix-prefetch-git @@ -17,9 +17,9 @@ branchName=$NIX_PREFETCH_GIT_BRANCH_NAME out=${out:-} http_proxy=${http_proxy:-} -# allow overwriting cacert's ca-bundle.crt with a custom one -# this can be done by setting NIX_GIT_SSL_CAINFO and NIX_SSL_CERT_FILE environment variables for the nix-daemon -GIT_SSL_CAINFO=${NIX_GIT_SSL_CAINFO:-$GIT_SSL_CAINFO} +# NOTE: use of NIX_GIT_SSL_CAINFO is for backwards compatibility; NIX_SSL_CERT_FILE is preferred +# as of PR#303307 +GIT_SSL_CAINFO=${NIX_GIT_SSL_CAINFO:-$NIX_SSL_CERT_FILE} # populated by clone_user_rev() fullRev= diff --git a/pkgs/build-support/go/module.nix b/pkgs/build-support/go/module.nix index 214b2603ff7f..bda01fc6f9b2 100644 --- a/pkgs/build-support/go/module.nix +++ b/pkgs/build-support/go/module.nix @@ -136,6 +136,7 @@ in exit 10 fi + export GIT_SSL_CAINFO=$NIX_SSL_CERT_FILE ${if finalAttrs.proxyVendor then '' mkdir -p "''${GOPATH}/pkg/mod/cache/download" go mod download diff --git a/pkgs/data/misc/cacert/setup-hook.sh b/pkgs/data/misc/cacert/setup-hook.sh index 93b682fbbd12..62361102648d 100644 --- a/pkgs/data/misc/cacert/setup-hook.sh +++ b/pkgs/data/misc/cacert/setup-hook.sh @@ -1,7 +1,7 @@ -export NIX_SSL_CERT_FILE=@out@/etc/ssl/certs/ca-bundle.crt +export NIX_SSL_CERT_FILE="${NIX_SSL_CERT_FILE:-@out@/etc/ssl/certs/ca-bundle.crt}" # compatibility # - openssl -export SSL_CERT_FILE=@out@/etc/ssl/certs/ca-bundle.crt +export SSL_CERT_FILE=$NIX_SSL_CERT_FILE # - Haskell x509-system -export SYSTEM_CERTIFICATE_PATH=@out@/etc/ssl/certs/ca-bundle.crt +export SYSTEM_CERTIFICATE_PATH=$NIX_SSL_CERT_FILE