diff options
author | Sandro Jäckel <sandro.jaeckel@sap.com> | 2021-09-15 16:17:05 +0200 |
---|---|---|
committer | Sandro Jäckel <sandro.jaeckel@sap.com> | 2021-09-28 15:00:11 +0200 |
commit | 6f53c067482743fd68a5beceeb1205fab0ebe4c4 (patch) | |
tree | ac45a5c0620420380cc537f9a0a3d971f932e5be /pkgs/build-support | |
parent | e3b5143614b6242b65f09b71850e1807126e2f33 (diff) |
fetchgit: add support for netrc file through impure NIX_GIT_SSL_CAINFO env
Diffstat (limited to 'pkgs/build-support')
-rw-r--r-- | pkgs/build-support/fetchgit/default.nix | 16 | ||||
-rwxr-xr-x | pkgs/build-support/fetchgit/nix-prefetch-git | 4 |
2 files changed, 18 insertions, 2 deletions
diff --git a/pkgs/build-support/fetchgit/default.nix b/pkgs/build-support/fetchgit/default.nix index 3222866dc781c..c139030ea9730 100644 --- a/pkgs/build-support/fetchgit/default.nix +++ b/pkgs/build-support/fetchgit/default.nix @@ -21,6 +21,11 @@ in postFetch ? "" , preferLocalBuild ? true , fetchLFS ? false +, # Shell code to build a netrc file for BASIC auth + netrcPhase ? null +, # Impure env vars (https://nixos.org/nix/manual/#sec-advanced-attributes) + # needed for netrcPhase + netrcImpureEnvVars ? [] }: /* NOTE: @@ -64,10 +69,17 @@ stdenvNoCC.mkDerivation { inherit url rev leaveDotGit fetchLFS fetchSubmodules deepClone branchName postFetch; + postHook = if netrcPhase == null then null else '' + ${netrcPhase} + # required that git uses the netrc file + mv {,.}netrc + export HOME=$PWD + ''; + GIT_SSL_CAINFO = "${cacert}/etc/ssl/certs/ca-bundle.crt"; - impureEnvVars = lib.fetchers.proxyImpureEnvVars ++ [ - "GIT_PROXY_COMMAND" "SOCKS_SERVER" + impureEnvVars = lib.fetchers.proxyImpureEnvVars ++ netrcImpureEnvVars ++ [ + "GIT_PROXY_COMMAND" "NIX_GIT_SSL_CAINFO" "SOCKS_SERVER" ]; inherit preferLocalBuild; diff --git a/pkgs/build-support/fetchgit/nix-prefetch-git b/pkgs/build-support/fetchgit/nix-prefetch-git index 6e869ab5e437f..10b402de61458 100755 --- a/pkgs/build-support/fetchgit/nix-prefetch-git +++ b/pkgs/build-support/fetchgit/nix-prefetch-git @@ -17,6 +17,10 @@ branchName=$NIX_PREFETCH_GIT_BRANCH_NAME out=${out:-} http_proxy=${http_proxy:-} +# allow overwritting cacert's ca-bundle.crt with a custom one +# this can be done by setting NIX_GIT_SSL_CAINFO and NIX_SSL_CERT_FILE enviroment variables for the nix-daemon +GIT_SSL_CAINFO=${NIX_GIT_SSL_CAINFO:-$GIT_SSL_CAINFO} + # populated by clone_user_rev() fullRev= humanReadableRev= |