forked from mirrors/nixpkgs
Merge pull request #24347 from spacekitteh/fetchGitRepo
fetchRepoProject: fixes; more options
This commit is contained in:
commit
8a919af23b
|
@ -1,10 +1,31 @@
|
||||||
{ stdenv, git, gitRepo, gnupg ? null, cacert }:
|
{ stdenv, git, gitRepo, gnupg ? null, cacert, copyPathsToStore }:
|
||||||
|
|
||||||
{ name, manifest, rev ? "HEAD", sha256 ? "", repoRepoURL ? "", repoRepoRev ? "", referenceDir ? ""
|
{ name, manifest, rev ? "HEAD", sha256, repoRepoURL ? "", repoRepoRev ? "", referenceDir ? ""
|
||||||
, localManifests ? []
|
, localManifests ? [], createMirror ? false, useArchive ? !createMirror
|
||||||
}:
|
}:
|
||||||
|
|
||||||
assert repoRepoRev != "" -> repoRepoURL != "";
|
assert repoRepoRev != "" -> repoRepoURL != "";
|
||||||
|
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"
|
||||||
|
(optionalString createMirror "--mirror")
|
||||||
|
(optionalString useArchive "--archive")
|
||||||
|
(optionalString (repoRepoURL != "") "--repo-url=${repoRepoURL}")
|
||||||
|
(optionalString (repoRepoRev != "") "--repo-branch=${repoRepoRev}")
|
||||||
|
(optionalString (referenceDir != "") "--reference=${referenceDir}")
|
||||||
|
];
|
||||||
|
|
||||||
|
local_manifests = copyPathsToStore localManifests;
|
||||||
|
|
||||||
|
in
|
||||||
|
|
||||||
with stdenv.lib;
|
with stdenv.lib;
|
||||||
|
|
||||||
|
@ -18,19 +39,21 @@ in
|
||||||
|
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
buildCommand = ''
|
buildCommand = ''
|
||||||
mkdir ./.repo
|
mkdir .repo
|
||||||
|
${optionalString (local_manifests != []) ''
|
||||||
mkdir ./.repo/local_manifests
|
mkdir ./.repo/local_manifests
|
||||||
for local_manifest in ${concatMapStringsSep " " toString localManifests}
|
for local_manifest in ${concatMapStringsSep " " toString local_manifests}
|
||||||
|
|
||||||
do
|
do
|
||||||
cp $local_manifest ./.repo/local_manifests/$(stripHash $local_manifest; echo $strippedName)
|
cp $local_manifest ./.repo/local_manifests/$(stripHash $local_manifest; echo $strippedName)
|
||||||
done
|
done
|
||||||
|
''}
|
||||||
|
|
||||||
export HOME=.repo
|
export HOME=.repo
|
||||||
repo init --manifest-url=${manifest} --manifest-branch=${rev} --depth=1 --no-clone-bundle \
|
repo init ${concatStringsSep " " repoInitFlags}
|
||||||
${concatStringsSep " " extraRepoInitFlags}
|
|
||||||
|
|
||||||
repo sync --jobs=$NIX_BUILD_CORES --current-branch
|
repo sync --jobs=$NIX_BUILD_CORES --current-branch
|
||||||
rm -rf $out/.repo
|
${optionalString (!createMirror) "rm -rf $out/.repo"}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
GIT_SSL_CAINFO = "${cacert}/etc/ssl/certs/ca-bundle.crt";
|
GIT_SSL_CAINFO = "${cacert}/etc/ssl/certs/ca-bundle.crt";
|
||||||
|
@ -40,7 +63,6 @@ stdenv.mkDerivation {
|
||||||
];
|
];
|
||||||
|
|
||||||
buildInputs = [git gitRepo cacert] ++ optional (gnupg != null) [gnupg] ;
|
buildInputs = [git gitRepo cacert] ++ optional (gnupg != null) [gnupg] ;
|
||||||
|
|
||||||
outputHashAlgo = "sha256";
|
outputHashAlgo = "sha256";
|
||||||
outputHashMode = "recursive";
|
outputHashMode = "recursive";
|
||||||
outputHash = sha256;
|
outputHash = sha256;
|
||||||
|
|
Loading…
Reference in a new issue