From 018a5ae2f4e01c0e7ccd63a58c308082387fc73b Mon Sep 17 00:00:00 2001 From: Michael Weiss Date: Sun, 17 Sep 2017 23:16:33 +0200 Subject: fetchRepoProject: Fetch into $out and make it deterministic Fetch into $out and remove all version control files to make it deterministic (.repo and all .git subdirectories - e.g. the .git/index files change every time). Additionally I've changed the default of "useArchive" to false because fetching with "--archive" will fail for some projects (e.g. "platform/external/iosched" from the AOSP). Now, this function should hopefully work for every tag of the AOSP. --- pkgs/build-support/fetchrepoproject/default.nix | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'pkgs/build-support/fetchrepoproject') diff --git a/pkgs/build-support/fetchrepoproject/default.nix b/pkgs/build-support/fetchrepoproject/default.nix index 2e5fbe79435..199c029d3b6 100644 --- a/pkgs/build-support/fetchrepoproject/default.nix +++ b/pkgs/build-support/fetchrepoproject/default.nix @@ -1,8 +1,9 @@ { stdenv, gitRepo, cacert, copyPathsToStore }: { name, manifest, rev ? "HEAD", sha256 +# Optional parameters: , repoRepoURL ? "", repoRepoRev ? "", referenceDir ? "" -, localManifests ? [], createMirror ? false, useArchive ? !createMirror +, localManifests ? [], createMirror ? false, useArchive ? false }: assert repoRepoRev != "" -> repoRepoURL != ""; @@ -51,6 +52,9 @@ in stdenv.mkDerivation { # Path must be absolute (e.g. for GnuPG: ~/.repoconfig/gnupg/pubring.kbx) export HOME="$(pwd)" + mkdir $out + cd $out + mkdir .repo ${optionalString (local_manifests != []) '' mkdir .repo/local_manifests @@ -61,6 +65,13 @@ in stdenv.mkDerivation { repo init ${concatStringsSep " " repoInitFlags} repo sync --jobs=$NIX_BUILD_CORES --current-branch - ${optionalString (!createMirror) "rm -rf $out/.repo"} + + # TODO: The git-index files (and probably the files in .repo as well) have + # different contents each time and will therefore change the final hash + # (i.e. creating a mirror probably won't work). + ${optionalString (!createMirror) '' + rm -rf .repo + find -type d -name '.git' -prune -exec rm -rf {} + + ''} ''; } -- cgit 1.4.1