From 57829cc246ef9d5d39cc6a94c92b7c0a17eba60a Mon Sep 17 00:00:00 2001 From: Zhong Jianxin Date: Mon, 24 Jan 2022 11:31:41 +0800 Subject: [PATCH] fetchgithub: Support sparseCheckout --- pkgs/build-support/fetchgithub/default.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/build-support/fetchgithub/default.nix b/pkgs/build-support/fetchgithub/default.nix index d40a0478baba..4e4162368b91 100644 --- a/pkgs/build-support/fetchgithub/default.nix +++ b/pkgs/build-support/fetchgithub/default.nix @@ -3,6 +3,7 @@ { owner, repo, rev, name ? "source" , fetchSubmodules ? false, leaveDotGit ? null , deepClone ? false, private ? false, forceFetchGit ? false +, sparseCheckout ? "" , githubBase ? "github.com", varPrefix ? null , ... # For hash agility }@args: @@ -10,7 +11,7 @@ let baseUrl = "https://${githubBase}/${owner}/${repo}"; passthruAttrs = removeAttrs args [ "owner" "repo" "rev" "fetchSubmodules" "forceFetchGit" "private" "githubBase" "varPrefix" ]; varBase = "NIX${if varPrefix == null then "" else "_${varPrefix}"}_GITHUB_PRIVATE_"; - useFetchGit = fetchSubmodules || (leaveDotGit == true) || deepClone || forceFetchGit; + useFetchGit = fetchSubmodules || (leaveDotGit == true) || deepClone || forceFetchGit || (sparseCheckout != ""); # We prefer fetchzip in cases we don't need submodules as the hash # is more stable in that case. fetcher = if useFetchGit then fetchgit else fetchzip; @@ -30,7 +31,7 @@ let }; fetcherArgs = (if useFetchGit then { - inherit rev deepClone fetchSubmodules; url = "${baseUrl}.git"; + inherit rev deepClone fetchSubmodules sparseCheckout; url = "${baseUrl}.git"; } // lib.optionalAttrs (leaveDotGit != null) { inherit leaveDotGit; } else { url = "${baseUrl}/archive/${rev}.tar.gz"; } ) // privateAttrs // passthruAttrs // { inherit name; };