mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-21 22:43:01 +00:00
fetchRepoProject: support hash
attribute, wrapping in withnormalizedHash
This commit is contained in:
parent
ac177dff93
commit
80cafd06e6
@ -1,83 +1,83 @@
|
|||||||
{ lib, stdenvNoCC, gitRepo, cacert, copyPathsToStore }:
|
{ lib, stdenvNoCC, gitRepo, cacert, copyPathsToStore }:
|
||||||
|
lib.fetchers.withNormalizedHash { } (
|
||||||
|
{ name, manifest, rev ? "HEAD", outputHash, outputHashAlgo
|
||||||
|
# Optional parameters:
|
||||||
|
, repoRepoURL ? "", repoRepoRev ? "", referenceDir ? "", manifestName ? ""
|
||||||
|
, localManifests ? [], createMirror ? false, useArchive ? false
|
||||||
|
}:
|
||||||
|
|
||||||
{ name, manifest, rev ? "HEAD", sha256
|
assert repoRepoRev != "" -> repoRepoURL != "";
|
||||||
# Optional parameters:
|
assert createMirror -> !useArchive;
|
||||||
, repoRepoURL ? "", repoRepoRev ? "", referenceDir ? "", manifestName ? ""
|
|
||||||
, localManifests ? [], createMirror ? false, useArchive ? false
|
|
||||||
}:
|
|
||||||
|
|
||||||
assert repoRepoRev != "" -> repoRepoURL != "";
|
let
|
||||||
assert createMirror -> !useArchive;
|
inherit (lib)
|
||||||
|
concatMapStringsSep
|
||||||
|
concatStringsSep
|
||||||
|
fetchers
|
||||||
|
optionalString
|
||||||
|
;
|
||||||
|
|
||||||
let
|
extraRepoInitFlags = [
|
||||||
inherit (lib)
|
(optionalString (repoRepoURL != "") "--repo-url=${repoRepoURL}")
|
||||||
concatMapStringsSep
|
(optionalString (repoRepoRev != "") "--repo-branch=${repoRepoRev}")
|
||||||
concatStringsSep
|
(optionalString (referenceDir != "") "--reference=${referenceDir}")
|
||||||
fetchers
|
(optionalString (manifestName != "") "--manifest-name=${manifestName}")
|
||||||
optionalString
|
];
|
||||||
;
|
|
||||||
|
|
||||||
extraRepoInitFlags = [
|
repoInitFlags = [
|
||||||
(optionalString (repoRepoURL != "") "--repo-url=${repoRepoURL}")
|
"--manifest-url=${manifest}"
|
||||||
(optionalString (repoRepoRev != "") "--repo-branch=${repoRepoRev}")
|
"--manifest-branch=${rev}"
|
||||||
(optionalString (referenceDir != "") "--reference=${referenceDir}")
|
"--depth=1"
|
||||||
(optionalString (manifestName != "") "--manifest-name=${manifestName}")
|
(optionalString createMirror "--mirror")
|
||||||
];
|
(optionalString useArchive "--archive")
|
||||||
|
] ++ extraRepoInitFlags;
|
||||||
|
|
||||||
repoInitFlags = [
|
local_manifests = copyPathsToStore localManifests;
|
||||||
"--manifest-url=${manifest}"
|
|
||||||
"--manifest-branch=${rev}"
|
|
||||||
"--depth=1"
|
|
||||||
(optionalString createMirror "--mirror")
|
|
||||||
(optionalString useArchive "--archive")
|
|
||||||
] ++ extraRepoInitFlags;
|
|
||||||
|
|
||||||
local_manifests = copyPathsToStore localManifests;
|
in stdenvNoCC.mkDerivation {
|
||||||
|
inherit name;
|
||||||
|
|
||||||
in stdenvNoCC.mkDerivation {
|
inherit cacert manifest rev repoRepoURL repoRepoRev referenceDir; # TODO
|
||||||
inherit name;
|
|
||||||
|
|
||||||
inherit cacert manifest rev repoRepoURL repoRepoRev referenceDir; # TODO
|
inherit outputHash outputHashAlgo;
|
||||||
|
outputHashMode = "recursive";
|
||||||
|
|
||||||
outputHashAlgo = "sha256";
|
preferLocalBuild = true;
|
||||||
outputHashMode = "recursive";
|
enableParallelBuilding = true;
|
||||||
outputHash = sha256;
|
|
||||||
|
|
||||||
preferLocalBuild = true;
|
impureEnvVars = fetchers.proxyImpureEnvVars ++ [
|
||||||
enableParallelBuilding = true;
|
"GIT_PROXY_COMMAND" "SOCKS_SERVER"
|
||||||
|
];
|
||||||
|
|
||||||
impureEnvVars = fetchers.proxyImpureEnvVars ++ [
|
nativeBuildInputs = [ gitRepo cacert ];
|
||||||
"GIT_PROXY_COMMAND" "SOCKS_SERVER"
|
|
||||||
];
|
|
||||||
|
|
||||||
nativeBuildInputs = [ gitRepo cacert ];
|
GIT_SSL_CAINFO = "${cacert}/etc/ssl/certs/ca-bundle.crt";
|
||||||
|
|
||||||
GIT_SSL_CAINFO = "${cacert}/etc/ssl/certs/ca-bundle.crt";
|
buildCommand = ''
|
||||||
|
# Path must be absolute (e.g. for GnuPG: ~/.repoconfig/gnupg/pubring.kbx)
|
||||||
|
export HOME="$(pwd)"
|
||||||
|
|
||||||
buildCommand = ''
|
mkdir $out
|
||||||
# Path must be absolute (e.g. for GnuPG: ~/.repoconfig/gnupg/pubring.kbx)
|
cd $out
|
||||||
export HOME="$(pwd)"
|
|
||||||
|
|
||||||
mkdir $out
|
mkdir .repo
|
||||||
cd $out
|
${optionalString (local_manifests != []) ''
|
||||||
|
mkdir .repo/local_manifests
|
||||||
|
for local_manifest in ${concatMapStringsSep " " toString local_manifests}; do
|
||||||
|
cp $local_manifest .repo/local_manifests/$(stripHash $local_manifest)
|
||||||
|
done
|
||||||
|
''}
|
||||||
|
|
||||||
mkdir .repo
|
repo init ${concatStringsSep " " repoInitFlags}
|
||||||
${optionalString (local_manifests != []) ''
|
repo sync --jobs=$NIX_BUILD_CORES --current-branch
|
||||||
mkdir .repo/local_manifests
|
|
||||||
for local_manifest in ${concatMapStringsSep " " toString local_manifests}; do
|
|
||||||
cp $local_manifest .repo/local_manifests/$(stripHash $local_manifest)
|
|
||||||
done
|
|
||||||
''}
|
|
||||||
|
|
||||||
repo init ${concatStringsSep " " repoInitFlags}
|
# TODO: The git-index files (and probably the files in .repo as well) have
|
||||||
repo sync --jobs=$NIX_BUILD_CORES --current-branch
|
# different contents each time and will therefore change the final hash
|
||||||
|
# (i.e. creating a mirror probably won't work).
|
||||||
# TODO: The git-index files (and probably the files in .repo as well) have
|
${optionalString (!createMirror) ''
|
||||||
# different contents each time and will therefore change the final hash
|
rm -rf .repo
|
||||||
# (i.e. creating a mirror probably won't work).
|
find -type d -name '.git' -prune -exec rm -rf {} +
|
||||||
${optionalString (!createMirror) ''
|
''}
|
||||||
rm -rf .repo
|
'';
|
||||||
find -type d -name '.git' -prune -exec rm -rf {} +
|
}
|
||||||
''}
|
)
|
||||||
'';
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user