fetchgit: add preFetch hook (#404488)

authored by philiptaron.tngl.sh and committed by

GitHub 3fd3d5bc 5eefa703

+14 -2
+6 -1
doc/build-helpers/fetchers.chapter.md
··· 773 774 : Whether to fetch LFS objects. 775 776 *`postFetch`* (String) 777 778 - : Shell code executed after the file has been fetched successfully. 779 This can do things like check or transform the file. 780 781 *`leaveDotGit`* (Boolean)
··· 773 774 : Whether to fetch LFS objects. 775 776 + *`preFetch`* (String) 777 + 778 + : Shell code to be executed before the repository has been fetched, to allow 779 + changing the environment the fetcher runs in. 780 + 781 *`postFetch`* (String) 782 783 + : Shell code executed after the repository has been fetched successfully. 784 This can do things like check or transform the file. 785 786 *`leaveDotGit`* (Boolean)
+2
pkgs/build-support/fetchgit/builder.sh
··· 6 7 echo "exporting $url (rev $rev) into $out" 8 9 $SHELL $fetcher --builder --url "$url" --out "$out" --rev "$rev" --name "$name" \ 10 ${leaveDotGit:+--leave-dotGit} \ 11 ${fetchLFS:+--fetch-lfs} \
··· 6 7 echo "exporting $url (rev $rev) into $out" 8 9 + runHook preFetch 10 + 11 $SHELL $fetcher --builder --url "$url" --out "$out" --rev "$rev" --name "$name" \ 12 ${leaveDotGit:+--leave-dotGit} \ 13 ${fetchLFS:+--fetch-lfs} \
+6 -1
pkgs/build-support/fetchgit/default.nix
··· 38 nonConeMode ? false, 39 name ? null, 40 nativeBuildInputs ? [ ], 41 # Shell code executed after the file has been fetched 42 # successfully. This can do things like check or transform the file. 43 postFetch ? "", ··· 75 server admins start using the new version? 76 */ 77 78 - assert deepClone -> leaveDotGit; 79 assert nonConeMode -> (sparseCheckout != [ ]); 80 81 let ··· 130 deepClone 131 branchName 132 nonConeMode 133 postFetch 134 ; 135 rev = revWithTag;
··· 38 nonConeMode ? false, 39 name ? null, 40 nativeBuildInputs ? [ ], 41 + # Shell code executed before the file has been fetched. This, in 42 + # particular, can do things like set NIX_PREFETCH_GIT_CHECKOUT_HOOK to 43 + # run operations between the checkout completing and deleting the .git 44 + # directory. 45 + preFetch ? "", 46 # Shell code executed after the file has been fetched 47 # successfully. This can do things like check or transform the file. 48 postFetch ? "", ··· 80 server admins start using the new version? 81 */ 82 83 assert nonConeMode -> (sparseCheckout != [ ]); 84 85 let ··· 134 deepClone 135 branchName 136 nonConeMode 137 + preFetch 138 postFetch 139 ; 140 rev = revWithTag;