nixpkgs/pkgs/build-support/fetchrepoproject/default.nix

52 lines
1.5 KiB
Nix
Raw Normal View History

2017-03-24 23:35:20 +00:00
{ stdenv, git, gitRepo, gnupg ? null, cacert }:
2017-03-24 23:35:20 +00:00
{ name, manifest, rev ? "HEAD", sha256 ? "", repoRepoURL ? "", repoRepoRev ? "", referenceDir ? ""
, localManifests ? []
}:
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
stdenv.mkDerivation {
2017-03-24 23:35:20 +00:00
buildCommand = ''
mkdir ./.repo
mkdir ./.repo/local_manifests
2017-03-24 23:35:20 +00:00
for local_manifest in ${concatMapStringsSep " " toString localManifests}
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}
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] ;
outputHashAlgo = "sha256";
outputHashMode = "recursive";
outputHash = sha256;
preferLocalBuild = true;
enableParallelBuilding = true;
inherit name cacert manifest rev repoRepoURL repoRepoRev referenceDir;
}