git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #138809 from SuperSandro2000/fetchgithub-private
commit6952befcb319d06957fdd581719d544b329a7dc6 authorSandro <sandro.jaeckel@gmail.com> dateFri 1 Oct 2021, 17:09 (5 years ago) parent78f552300dc3dc
3 files changed+22−8
pkgs/build-support/fetchgit/default.nix+14−2 pkgs/build-support/fetchgit/nix-prefetch-git+4 pkgs/build-support/fetchgithub/default.nix+4−6
pkgs/build-support/fetchgit/default.nix+14−2
@@ -21,6 +21,11 @@ in
2121 postFetch ? ""
2222, preferLocalBuild ? true
2323, 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 ? []
2429}:
2530
2631/* NOTE:
@@ -64,10 +69,17 @@ stdenvNoCC.mkDerivation {
6469
6570 inherit url rev leaveDotGit fetchLFS fetchSubmodules deepClone branchName postFetch;
6671
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+
6779 GIT_SSL_CAINFO = "${cacert}/etc/ssl/certs/ca-bundle.crt";
6880
69− impureEnvVars = lib.fetchers.proxyImpureEnvVars ++ [
70− "GIT_PROXY_COMMAND" "SOCKS_SERVER"
81+ impureEnvVars = lib.fetchers.proxyImpureEnvVars ++ netrcImpureEnvVars ++ [
82+ "GIT_PROXY_COMMAND" "NIX_GIT_SSL_CAINFO" "SOCKS_SERVER"
7183 ];
7284
7385 inherit preferLocalBuild;
pkgs/build-support/fetchgit/nix-prefetch-git+4
@@ -17,6 +17,10 @@ branchName=$NIX_PREFETCH_GIT_BRANCH_NAME
1717out=${out:-}
1818http_proxy=${http_proxy:-}
1919
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+
2024# populated by clone_user_rev()
2125fullRev=
2226humanReadableRev=
pkgs/build-support/fetchgithub/default.nix+4−6
@@ -2,7 +2,7 @@
22
33{ owner, repo, rev, name ? "source"
44, fetchSubmodules ? false, leaveDotGit ? null
5−, deepClone ? false, private ? false
5+, deepClone ? false, private ? false, forceFetchGit ? false
66, githubBase ? "github.com", varPrefix ? null
77, ... # For hash agility
88}@args:
@@ -10,7 +10,7 @@ let
1010 baseUrl = "https://${githubBase}/${owner}/${repo}";
1111 passthruAttrs = removeAttrs args [ "owner" "repo" "rev" "fetchSubmodules" "private" "githubBase" "varPrefix" ];
1212 varBase = "NIX${if varPrefix == null then "" else "_${varPrefix}"}_GITHUB_PRIVATE_";
13− useFetchGit = fetchSubmodules || (leaveDotGit == true) || deepClone;
13+ useFetchGit = fetchSubmodules || (leaveDotGit == true) || deepClone || forceFetchGit;
1414 # We prefer fetchzip in cases we don't need submodules as the hash
1515 # is more stable in that case.
1616 fetcher = if useFetchGit then fetchgit else fetchzip;
@@ -32,10 +32,8 @@ let
3232 then {
3333 inherit rev deepClone fetchSubmodules; url = "${baseUrl}.git";
3434 } // lib.optionalAttrs (leaveDotGit != null) { inherit leaveDotGit; }
35− else ({ url = "${baseUrl}/archive/${rev}.tar.gz"; } // privateAttrs)
36− ) // passthruAttrs // { inherit name; };
35+ else { url = "${baseUrl}/archive/${rev}.tar.gz"; }
36+ ) // privateAttrs // passthruAttrs // { inherit name; };
3737in
3838
39−assert private -> !useFetchGit;
40−
4139fetcher fetcherArgs // { meta.homepage = baseUrl; inherit rev; }