summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorJonathan Ringer <jonringer117@gmail.com>2020-12-04 23:32:48 -0800
committerJonathan Ringer <jonringer@users.noreply.github.com>2021-01-11 09:41:06 -0800
commit741285611f08230f44b443f0b2788dd93c4ba8d0 (patch)
treee208cefdabd4d67baeaa307817a159e58abec0ec /pkgs
parentecf84de70c91cbb1b540f58391ffb95f4fe53445 (diff)
downloadnixpkgs-741285611f08230f44b443f0b2788dd93c4ba8d0.tar
nixpkgs-741285611f08230f44b443f0b2788dd93c4ba8d0.tar.gz
nixpkgs-741285611f08230f44b443f0b2788dd93c4ba8d0.tar.bz2
nixpkgs-741285611f08230f44b443f0b2788dd93c4ba8d0.tar.lz
nixpkgs-741285611f08230f44b443f0b2788dd93c4ba8d0.tar.xz
nixpkgs-741285611f08230f44b443f0b2788dd93c4ba8d0.tar.zst
nixpkgs-741285611f08230f44b443f0b2788dd93c4ba8d0.zip
fetchgit: add lfs support
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/build-support/fetchgit/builder.sh1
-rw-r--r--pkgs/build-support/fetchgit/default.nix9
-rwxr-xr-xpkgs/build-support/fetchgit/nix-prefetch-git7
3 files changed, 14 insertions, 3 deletions
diff --git a/pkgs/build-support/fetchgit/builder.sh b/pkgs/build-support/fetchgit/builder.sh
index 6ae46469738..0047a335c76 100644
--- a/pkgs/build-support/fetchgit/builder.sh
+++ b/pkgs/build-support/fetchgit/builder.sh
@@ -8,6 +8,7 @@ header "exporting $url (rev $rev) into $out"
 
 $SHELL $fetcher --builder --url "$url" --out "$out" --rev "$rev" \
   ${leaveDotGit:+--leave-dotGit} \
+  ${fetchLFS:+--fetch-lfs} \
   ${deepClone:+--deepClone} \
   ${fetchSubmodules:+--fetch-submodules} \
   ${branchName:+--branch-name "$branchName"}
diff --git a/pkgs/build-support/fetchgit/default.nix b/pkgs/build-support/fetchgit/default.nix
index 0405951a9e4..5f5ded128de 100644
--- a/pkgs/build-support/fetchgit/default.nix
+++ b/pkgs/build-support/fetchgit/default.nix
@@ -1,4 +1,4 @@
-{stdenvNoCC, git, cacert}: let
+{stdenvNoCC, git, git-lfs, cacert}: let
   urlToName = url: rev: let
     inherit (stdenvNoCC.lib) removeSuffix splitString last;
     base = last (splitString ":" (baseNameOf (removeSuffix "/" url)));
@@ -20,6 +20,7 @@ in
   # successfully. This can do things like check or transform the file.
   postFetch ? ""
 , preferLocalBuild ? true
+, fetchLFS ? false
 }:
 
 /* NOTE:
@@ -53,13 +54,15 @@ stdenvNoCC.mkDerivation {
   inherit name;
   builder = ./builder.sh;
   fetcher = ./nix-prefetch-git;  # This must be a string to ensure it's called with bash.
-  nativeBuildInputs = [git];
+
+  nativeBuildInputs = [ git ]
+    ++ stdenvNoCC.lib.optionals fetchLFS [ git-lfs ];
 
   outputHashAlgo = "sha256";
   outputHashMode = "recursive";
   outputHash = sha256;
 
-  inherit url rev leaveDotGit fetchSubmodules deepClone branchName postFetch;
+  inherit url rev leaveDotGit fetchLFS fetchSubmodules deepClone branchName postFetch;
 
   GIT_SSL_CAINFO = "${cacert}/etc/ssl/certs/ca-bundle.crt";
 
diff --git a/pkgs/build-support/fetchgit/nix-prefetch-git b/pkgs/build-support/fetchgit/nix-prefetch-git
index 43f7c5acd5a..3cb115c5e6e 100755
--- a/pkgs/build-support/fetchgit/nix-prefetch-git
+++ b/pkgs/build-support/fetchgit/nix-prefetch-git
@@ -9,6 +9,7 @@ hashType=$NIX_HASH_ALGO
 deepClone=$NIX_PREFETCH_GIT_DEEP_CLONE
 leaveDotGit=$NIX_PREFETCH_GIT_LEAVE_DOT_GIT
 fetchSubmodules=
+fetchLFS=
 builder=
 branchName=$NIX_PREFETCH_GIT_BRANCH_NAME
 
@@ -72,6 +73,7 @@ for arg; do
             --quiet) QUIET=true;;
             --no-deepClone) deepClone=;;
             --leave-dotGit) leaveDotGit=true;;
+            --fetch-lfs) fetchLFS=true;;
             --fetch-submodules) fetchSubmodules=true;;
             --builder) builder=true;;
             -h|--help) usage; exit;;
@@ -283,6 +285,11 @@ clone_user_rev() {
     local url="$2"
     local rev="${3:-HEAD}"
 
+    if [ -n "$fetchLFS" ]; then
+        HOME=$TMPDIR
+        git lfs install
+    fi
+
     # Perform the checkout.
     case "$rev" in
         HEAD|refs/*)