Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetchgit: add lfs support #105998

Merged
merged 1 commit into from
Jan 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pkgs/build-support/fetchgit/builder.sh
Original file line number Diff line number Diff line change
@@ -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"}
9 changes: 6 additions & 3 deletions pkgs/build-support/fetchgit/default.nix
Original file line number Diff line number Diff line change
@@ -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";

7 changes: 7 additions & 0 deletions pkgs/build-support/fetchgit/nix-prefetch-git
Original file line number Diff line number Diff line change
@@ -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/*)