2017-03-24 23:35:20 +00:00
|
|
|
{ stdenv, git, gitRepo, gnupg ? null, cacert }:
|
2017-03-23 03:22:44 +00:00
|
|
|
|
2017-03-24 23:35:20 +00:00
|
|
|
{ name, manifest, rev ? "HEAD", sha256 ? "", repoRepoURL ? "", repoRepoRev ? "", referenceDir ? ""
|
|
|
|
, localManifests ? []
|
|
|
|
}:
|
2017-03-23 03:22:44 +00:00
|
|
|
|
|
|
|
assert repoRepoRev != "" -> repoRepoURL != "";
|
|
|
|
|
2017-03-24 23:35:20 +00:00
|
|
|
with stdenv.lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
extraRepoInitFlags = [
|
|
|
|
(optionalString (repoRepoURL != "") "--repo-url=${repoRepoURL}")
|
|
|
|
(optionalString (repoRepoRev != "") "--repo-branch=${repoRepoRev}")
|
|
|
|
(optionalString (referenceDir != "") "--reference=${referenceDir}")
|
|
|
|
];
|
|
|
|
in
|
|
|
|
|
2017-03-23 03:22:44 +00:00
|
|
|
stdenv.mkDerivation {
|
2017-03-24 23:35:20 +00:00
|
|
|
buildCommand = ''
|
2017-03-23 03:22:44 +00:00
|
|
|
mkdir ./.repo
|
|
|
|
mkdir ./.repo/local_manifests
|
2017-03-24 23:35:20 +00:00
|
|
|
for local_manifest in ${concatMapStringsSep " " toString localManifests}
|
2017-03-23 03:22:44 +00:00
|
|
|
do
|
|
|
|
cp $local_manifest ./.repo/local_manifests/$(stripHash $local_manifest; echo $strippedName)
|
|
|
|
done
|
|
|
|
|
|
|
|
export HOME=.repo
|
2017-03-24 23:35:20 +00:00
|
|
|
repo init --manifest-url=${manifest} --manifest-branch=${rev} --depth=1 --no-clone-bundle \
|
|
|
|
${concatStringsSep " " extraRepoInitFlags}
|
|
|
|
|
2017-03-23 03:22:44 +00:00
|
|
|
repo sync --jobs=$NIX_BUILD_CORES --current-branch
|
|
|
|
rm -rf $out/.repo
|
|
|
|
'';
|
|
|
|
|
|
|
|
GIT_SSL_CAINFO = "${cacert}/etc/ssl/certs/ca-bundle.crt";
|
|
|
|
|
|
|
|
impureEnvVars = stdenv.lib.fetchers.proxyImpureEnvVars ++ [
|
|
|
|
"GIT_PROXY_COMMAND" "SOCKS_SERVER"
|
|
|
|
];
|
|
|
|
|
2017-03-24 23:35:20 +00:00
|
|
|
buildInputs = [git gitRepo cacert] ++ optional (gnupg != null) [gnupg] ;
|
2017-03-23 03:22:44 +00:00
|
|
|
|
|
|
|
outputHashAlgo = "sha256";
|
|
|
|
outputHashMode = "recursive";
|
|
|
|
outputHash = sha256;
|
|
|
|
|
|
|
|
preferLocalBuild = true;
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
inherit name cacert manifest rev repoRepoURL repoRepoRev referenceDir;
|
|
|
|
}
|