2017-03-26 11:59:08 +02:00
|
|
|
{ stdenv, git, gitRepo, gnupg ? null, cacert, copyPathsToStore }:
|
2017-03-23 04:22:44 +01:00
|
|
|
|
2017-03-26 11:59:08 +02:00
|
|
|
{ name, manifest, rev ? "HEAD", sha256, repoRepoURL ? "", repoRepoRev ? "", referenceDir ? ""
|
|
|
|
, localManifests ? [], createMirror ? false, useArchive ? !createMirror
|
|
|
|
}:
|
2017-03-23 04:22:44 +01:00
|
|
|
|
|
|
|
assert repoRepoRev != "" -> repoRepoURL != "";
|
2017-03-26 11:59:08 +02:00
|
|
|
assert createMirror -> !useArchive;
|
|
|
|
|
|
|
|
with stdenv.lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
repoInitFlags = [
|
|
|
|
"--manifest-url=${manifest}"
|
|
|
|
"--manifest-branch=${rev}"
|
|
|
|
"--depth=1"
|
|
|
|
#TODO: fetching clone.bundle seems to fail spectacularly inside a sandbox.
|
|
|
|
"--no-clone-bundle"
|
2017-03-27 07:04:02 +02:00
|
|
|
(optionalString createMirror "--mirror")
|
2017-03-26 11:59:08 +02:00
|
|
|
(optionalString useArchive "--archive")
|
|
|
|
(optionalString (repoRepoURL != "") "--repo-url=${repoRepoURL}")
|
|
|
|
(optionalString (repoRepoRev != "") "--repo-branch=${repoRepoRev}")
|
|
|
|
(optionalString (referenceDir != "") "--reference=${referenceDir}")
|
|
|
|
];
|
|
|
|
|
|
|
|
local_manifests = copyPathsToStore localManifests;
|
|
|
|
|
|
|
|
in
|
2017-03-23 04:22:44 +01:00
|
|
|
|
2017-03-25 00:35:20 +01:00
|
|
|
with stdenv.lib;
|
2017-03-26 11:59:08 +02:00
|
|
|
|
2017-03-25 00:35:20 +01:00
|
|
|
let
|
|
|
|
extraRepoInitFlags = [
|
|
|
|
(optionalString (repoRepoURL != "") "--repo-url=${repoRepoURL}")
|
|
|
|
(optionalString (repoRepoRev != "") "--repo-branch=${repoRepoRev}")
|
|
|
|
(optionalString (referenceDir != "") "--reference=${referenceDir}")
|
|
|
|
];
|
|
|
|
in
|
|
|
|
|
2017-03-23 04:22:44 +01:00
|
|
|
stdenv.mkDerivation {
|
2017-03-26 11:59:08 +02:00
|
|
|
buildCommand = ''
|
|
|
|
mkdir .repo
|
|
|
|
${optionalString (local_manifests != []) ''
|
2017-03-23 04:22:44 +01:00
|
|
|
mkdir ./.repo/local_manifests
|
2017-03-26 11:59:08 +02:00
|
|
|
for local_manifest in ${concatMapStringsSep " " toString local_manifests}
|
2017-03-26 12:17:03 +02:00
|
|
|
|
2017-03-23 04:22:44 +01:00
|
|
|
do
|
|
|
|
cp $local_manifest ./.repo/local_manifests/$(stripHash $local_manifest; echo $strippedName)
|
|
|
|
done
|
2017-03-26 11:59:08 +02:00
|
|
|
''}
|
2017-03-23 04:22:44 +01:00
|
|
|
|
|
|
|
export HOME=.repo
|
2017-03-26 11:59:08 +02:00
|
|
|
repo init ${concatStringsSep " " repoInitFlags}
|
|
|
|
|
2017-03-23 04:22:44 +01:00
|
|
|
repo sync --jobs=$NIX_BUILD_CORES --current-branch
|
2017-03-26 13:55:41 +02:00
|
|
|
${optionalString (!createMirror) "rm -rf $out/.repo"}
|
2017-03-23 04:22:44 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
GIT_SSL_CAINFO = "${cacert}/etc/ssl/certs/ca-bundle.crt";
|
|
|
|
|
|
|
|
impureEnvVars = stdenv.lib.fetchers.proxyImpureEnvVars ++ [
|
|
|
|
"GIT_PROXY_COMMAND" "SOCKS_SERVER"
|
|
|
|
];
|
|
|
|
|
2017-03-26 11:59:08 +02:00
|
|
|
buildInputs = [git gitRepo cacert] ++ optional (gnupg != null) [gnupg] ;
|
2017-03-23 04:22:44 +01:00
|
|
|
outputHashAlgo = "sha256";
|
|
|
|
outputHashMode = "recursive";
|
|
|
|
outputHash = sha256;
|
|
|
|
|
|
|
|
preferLocalBuild = true;
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
inherit name cacert manifest rev repoRepoURL repoRepoRev referenceDir;
|
|
|
|
}
|