Merge pull request #138809 from SuperSandro2000/fetchgithub-private

authored by Sandro and committed by GitHub 6952befc 78f5523a

+22 -8
+14 -2
pkgs/build-support/fetchgit/default.nix
··· 21 postFetch ? "" 22 , preferLocalBuild ? true 23 , fetchLFS ? false 24 }: 25 26 /* NOTE: ··· 64 65 inherit url rev leaveDotGit fetchLFS fetchSubmodules deepClone branchName postFetch; 66 67 GIT_SSL_CAINFO = "${cacert}/etc/ssl/certs/ca-bundle.crt"; 68 69 - impureEnvVars = lib.fetchers.proxyImpureEnvVars ++ [ 70 - "GIT_PROXY_COMMAND" "SOCKS_SERVER" 71 ]; 72 73 inherit preferLocalBuild;
··· 21 postFetch ? "" 22 , preferLocalBuild ? true 23 , fetchLFS ? false 24 + , # Shell code to build a netrc file for BASIC auth 25 + netrcPhase ? null 26 + , # Impure env vars (https://nixos.org/nix/manual/#sec-advanced-attributes) 27 + # needed for netrcPhase 28 + netrcImpureEnvVars ? [] 29 }: 30 31 /* NOTE: ··· 69 70 inherit url rev leaveDotGit fetchLFS fetchSubmodules deepClone branchName postFetch; 71 72 + postHook = if netrcPhase == null then null else '' 73 + ${netrcPhase} 74 + # required that git uses the netrc file 75 + mv {,.}netrc 76 + export HOME=$PWD 77 + ''; 78 + 79 GIT_SSL_CAINFO = "${cacert}/etc/ssl/certs/ca-bundle.crt"; 80 81 + impureEnvVars = lib.fetchers.proxyImpureEnvVars ++ netrcImpureEnvVars ++ [ 82 + "GIT_PROXY_COMMAND" "NIX_GIT_SSL_CAINFO" "SOCKS_SERVER" 83 ]; 84 85 inherit preferLocalBuild;
+4
pkgs/build-support/fetchgit/nix-prefetch-git
··· 17 out=${out:-} 18 http_proxy=${http_proxy:-} 19 20 # populated by clone_user_rev() 21 fullRev= 22 humanReadableRev=
··· 17 out=${out:-} 18 http_proxy=${http_proxy:-} 19 20 + # allow overwritting cacert's ca-bundle.crt with a custom one 21 + # this can be done by setting NIX_GIT_SSL_CAINFO and NIX_SSL_CERT_FILE enviroment variables for the nix-daemon 22 + GIT_SSL_CAINFO=${NIX_GIT_SSL_CAINFO:-$GIT_SSL_CAINFO} 23 + 24 # populated by clone_user_rev() 25 fullRev= 26 humanReadableRev=
+4 -6
pkgs/build-support/fetchgithub/default.nix
··· 2 3 { owner, repo, rev, name ? "source" 4 , fetchSubmodules ? false, leaveDotGit ? null 5 - , deepClone ? false, private ? false 6 , githubBase ? "github.com", varPrefix ? null 7 , ... # For hash agility 8 }@args: ··· 10 baseUrl = "https://${githubBase}/${owner}/${repo}"; 11 passthruAttrs = removeAttrs args [ "owner" "repo" "rev" "fetchSubmodules" "private" "githubBase" "varPrefix" ]; 12 varBase = "NIX${if varPrefix == null then "" else "_${varPrefix}"}_GITHUB_PRIVATE_"; 13 - useFetchGit = fetchSubmodules || (leaveDotGit == true) || deepClone; 14 # We prefer fetchzip in cases we don't need submodules as the hash 15 # is more stable in that case. 16 fetcher = if useFetchGit then fetchgit else fetchzip; ··· 32 then { 33 inherit rev deepClone fetchSubmodules; url = "${baseUrl}.git"; 34 } // lib.optionalAttrs (leaveDotGit != null) { inherit leaveDotGit; } 35 - else ({ url = "${baseUrl}/archive/${rev}.tar.gz"; } // privateAttrs) 36 - ) // passthruAttrs // { inherit name; }; 37 in 38 - 39 - assert private -> !useFetchGit; 40 41 fetcher fetcherArgs // { meta.homepage = baseUrl; inherit rev; }
··· 2 3 { owner, repo, rev, name ? "source" 4 , fetchSubmodules ? false, leaveDotGit ? null 5 + , deepClone ? false, private ? false, forceFetchGit ? false 6 , githubBase ? "github.com", varPrefix ? null 7 , ... # For hash agility 8 }@args: ··· 10 baseUrl = "https://${githubBase}/${owner}/${repo}"; 11 passthruAttrs = removeAttrs args [ "owner" "repo" "rev" "fetchSubmodules" "private" "githubBase" "varPrefix" ]; 12 varBase = "NIX${if varPrefix == null then "" else "_${varPrefix}"}_GITHUB_PRIVATE_"; 13 + useFetchGit = fetchSubmodules || (leaveDotGit == true) || deepClone || forceFetchGit; 14 # We prefer fetchzip in cases we don't need submodules as the hash 15 # is more stable in that case. 16 fetcher = if useFetchGit then fetchgit else fetchzip; ··· 32 then { 33 inherit rev deepClone fetchSubmodules; url = "${baseUrl}.git"; 34 } // lib.optionalAttrs (leaveDotGit != null) { inherit leaveDotGit; } 35 + else { url = "${baseUrl}/archive/${rev}.tar.gz"; } 36 + ) // privateAttrs // passthruAttrs // { inherit name; }; 37 in 38 39 fetcher fetcherArgs // { meta.homepage = baseUrl; inherit rev; }