1 { lib, stdenvNoCC, gitRepo, cacert, copyPathsToStore }:
2 lib.fetchers.withNormalizedHash { } (
3 { name, manifest, rev ? "HEAD", outputHash, outputHashAlgo
5 , repoRepoURL ? "", repoRepoRev ? "", referenceDir ? "", manifestName ? ""
6 , localManifests ? [], createMirror ? false, useArchive ? false
9 assert repoRepoRev != "" -> repoRepoURL != "";
10 assert createMirror -> !useArchive;
20 extraRepoInitFlags = [
21 (optionalString (repoRepoURL != "") "--repo-url=${repoRepoURL}")
22 (optionalString (repoRepoRev != "") "--repo-branch=${repoRepoRev}")
23 (optionalString (referenceDir != "") "--reference=${referenceDir}")
24 (optionalString (manifestName != "") "--manifest-name=${manifestName}")
28 "--manifest-url=${manifest}"
29 "--manifest-branch=${rev}"
31 (optionalString createMirror "--mirror")
32 (optionalString useArchive "--archive")
33 ] ++ extraRepoInitFlags;
35 local_manifests = copyPathsToStore localManifests;
37 in stdenvNoCC.mkDerivation {
40 inherit cacert manifest rev repoRepoURL repoRepoRev referenceDir; # TODO
42 inherit outputHash outputHashAlgo;
43 outputHashMode = "recursive";
45 preferLocalBuild = true;
46 enableParallelBuilding = true;
48 impureEnvVars = fetchers.proxyImpureEnvVars ++ [
49 "GIT_PROXY_COMMAND" "SOCKS_SERVER"
52 nativeBuildInputs = [ gitRepo cacert ];
54 GIT_SSL_CAINFO = "${cacert}/etc/ssl/certs/ca-bundle.crt";
57 # Path must be absolute (e.g. for GnuPG: ~/.repoconfig/gnupg/pubring.kbx)
64 ${optionalString (local_manifests != []) ''
65 mkdir .repo/local_manifests
66 for local_manifest in ${concatMapStringsSep " " toString local_manifests}; do
67 cp $local_manifest .repo/local_manifests/$(stripHash $local_manifest)
71 repo init ${concatStringsSep " " repoInitFlags}
72 repo sync --jobs=$NIX_BUILD_CORES --current-branch
74 # TODO: The git-index files (and probably the files in .repo as well) have
75 # different contents each time and will therefore change the final hash
76 # (i.e. creating a mirror probably won't work).
77 ${optionalString (!createMirror) ''
79 find -type d -name '.git' -prune -exec rm -rf {} +