git.iko.soy/typeable/nixpkgs
on master help sign in
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.

commit018a5ae2f4e01c0e7ccd63a58c308082387fc73b authorMichael Weiss <dev.primeos@gmail.com> dateSun 17 Sep 2017, 23:16 (9 years ago) parent7db2916
1 file changed+13−2
pkgs/build-support/fetchrepoproject/default.nix+13−2
pkgs/build-support/fetchrepoproject/default.nix+13−2
@@ -1,8 +1,9 @@
11{ stdenv, gitRepo, cacert, copyPathsToStore }:
22
33{ name, manifest, rev ? "HEAD", sha256
4+# Optional parameters:
45, repoRepoURL ? "", repoRepoRev ? "", referenceDir ? ""
5−, localManifests ? [], createMirror ? false, useArchive ? !createMirror
6+, localManifests ? [], createMirror ? false, useArchive ? false
67}:
78
89assert repoRepoRev != "" -> repoRepoURL != "";
@@ -51,6 +52,9 @@ in stdenv.mkDerivation {
5152 # Path must be absolute (e.g. for GnuPG: ~/.repoconfig/gnupg/pubring.kbx)
5253 export HOME="$(pwd)"
5354
55+ mkdir $out
56+ cd $out
57+
5458 mkdir .repo
5559 ${optionalString (local_manifests != []) ''
5660 mkdir .repo/local_manifests
@@ -61,6 +65,13 @@ in stdenv.mkDerivation {
6165
6266 repo init ${concatStringsSep " " repoInitFlags}
6367 repo sync --jobs=$NIX_BUILD_CORES --current-branch
64− ${optionalString (!createMirror) "rm -rf $out/.repo"}
68+
69+ # TODO: The git-index files (and probably the files in .repo as well) have
70+ # different contents each time and will therefore change the final hash
71+ # (i.e. creating a mirror probably won't work).
72+ ${optionalString (!createMirror) ''
73+ rm -rf .repo
74+ find -type d -name '.git' -prune -exec rm -rf {} +
75+ ''}
6576 '';
6677}