git.iko.soy/typeable/nixpkgs
on master help sign in
fetchgit: add lfs support
commit741285611f08230f44b443f0b2788dd93c4ba8d0 authorJonathan Ringer <jonringer117@gmail.com> dateFri 4 Dec 2020, 23:32 (6 years ago) parentecf84de
3 files changed+14−3
pkgs/build-support/fetchgit/builder.sh+1 pkgs/build-support/fetchgit/default.nix+6−3 pkgs/build-support/fetchgit/nix-prefetch-git+7
pkgs/build-support/fetchgit/builder.sh+1
@@ -8,6 +8,7 @@ header "exporting $url (rev $rev) into $out"
88
99$SHELL $fetcher --builder --url "$url" --out "$out" --rev "$rev" \
1010 ${leaveDotGit:+--leave-dotGit} \
11+ ${fetchLFS:+--fetch-lfs} \
1112 ${deepClone:+--deepClone} \
1213 ${fetchSubmodules:+--fetch-submodules} \
1314 ${branchName:+--branch-name "$branchName"}
pkgs/build-support/fetchgit/default.nix+6−3
@@ -1,4 +1,4 @@
1−{stdenvNoCC, git, cacert}: let
1+{stdenvNoCC, git, git-lfs, cacert}: let
22 urlToName = url: rev: let
33 inherit (stdenvNoCC.lib) removeSuffix splitString last;
44 base = last (splitString ":" (baseNameOf (removeSuffix "/" url)));
@@ -20,6 +20,7 @@ in
2020 # successfully. This can do things like check or transform the file.
2121 postFetch ? ""
2222, preferLocalBuild ? true
23+, fetchLFS ? false
2324}:
2425
2526/* NOTE:
@@ -53,13 +54,15 @@ stdenvNoCC.mkDerivation {
5354 inherit name;
5455 builder = ./builder.sh;
5556 fetcher = ./nix-prefetch-git; # This must be a string to ensure it's called with bash.
56− nativeBuildInputs = [git];
57+
58+ nativeBuildInputs = [ git ]
59+ ++ stdenvNoCC.lib.optionals fetchLFS [ git-lfs ];
5760
5861 outputHashAlgo = "sha256";
5962 outputHashMode = "recursive";
6063 outputHash = sha256;
6164
62− inherit url rev leaveDotGit fetchSubmodules deepClone branchName postFetch;
65+ inherit url rev leaveDotGit fetchLFS fetchSubmodules deepClone branchName postFetch;
6366
6467 GIT_SSL_CAINFO = "${cacert}/etc/ssl/certs/ca-bundle.crt";
6568
pkgs/build-support/fetchgit/nix-prefetch-git+7
@@ -9,6 +9,7 @@ hashType=$NIX_HASH_ALGO
99deepClone=$NIX_PREFETCH_GIT_DEEP_CLONE
1010leaveDotGit=$NIX_PREFETCH_GIT_LEAVE_DOT_GIT
1111fetchSubmodules=
12+fetchLFS=
1213builder=
1314branchName=$NIX_PREFETCH_GIT_BRANCH_NAME
1415
@@ -72,6 +73,7 @@ for arg; do
7273 --quiet) QUIET=true;;
7374 --no-deepClone) deepClone=;;
7475 --leave-dotGit) leaveDotGit=true;;
76+ --fetch-lfs) fetchLFS=true;;
7577 --fetch-submodules) fetchSubmodules=true;;
7678 --builder) builder=true;;
7779 -h|--help) usage; exit;;
@@ -283,6 +285,11 @@ clone_user_rev() {
283285 local url="$2"
284286 local rev="${3:-HEAD}"
285287
288+ if [ -n "$fetchLFS" ]; then
289+ HOME=$TMPDIR
290+ git lfs install
291+ fi
292+
286293 # Perform the checkout.
287294 case "$rev" in
288295 HEAD|refs/*)