diff options
author | Nicolas Benes <nbenes.gh@xandea.de> | 2022-11-07 19:42:19 +0100 |
---|---|---|
committer | Nicolas Benes <nbenes.gh@xandea.de> | 2022-11-15 19:45:33 +0100 |
commit | f6b07f0e2f5834b1fd6432a0f4c2bc11096e53ed (patch) | |
tree | 2fe547a476d49c253d605f78dfe06f37516463f4 /pkgs/build-support/fetchgit/default.nix | |
parent | 79e84ba085c152323f9f960d7b7e34730731f2bf (diff) | |
download | nixpkgs-f6b07f0e2f5834b1fd6432a0f4c2bc11096e53ed.tar nixpkgs-f6b07f0e2f5834b1fd6432a0f4c2bc11096e53ed.tar.gz nixpkgs-f6b07f0e2f5834b1fd6432a0f4c2bc11096e53ed.tar.bz2 nixpkgs-f6b07f0e2f5834b1fd6432a0f4c2bc11096e53ed.tar.lz nixpkgs-f6b07f0e2f5834b1fd6432a0f4c2bc11096e53ed.tar.xz nixpkgs-f6b07f0e2f5834b1fd6432a0f4c2bc11096e53ed.tar.zst nixpkgs-f6b07f0e2f5834b1fd6432a0f4c2bc11096e53ed.zip |
fetchgit: make sparseCheckout a list of strings
The `sparseCheckout` argument allows the user to specify directories or patterns of files, which Git uses to filter files it should check-out. Git expects a multi-line string on stdin ("newline-delimited list", see `git-sparse-checkout(1)`), but within nixpkgs it is more consistent to use a list of strings instead. The list elements are joined to a multi-line string only before passing it to the builder script. A deprecation warning is emitted if a (multi-line) string is passed to `sparseCheckout`, but for the time being it is still accepted.
Diffstat (limited to 'pkgs/build-support/fetchgit/default.nix')
-rw-r--r-- | pkgs/build-support/fetchgit/default.nix | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/pkgs/build-support/fetchgit/default.nix b/pkgs/build-support/fetchgit/default.nix index f516c3d5a03..1fec0c88747 100644 --- a/pkgs/build-support/fetchgit/default.nix +++ b/pkgs/build-support/fetchgit/default.nix @@ -15,7 +15,7 @@ in { url, rev ? "HEAD", md5 ? "", sha256 ? "", hash ? "", leaveDotGit ? deepClone , fetchSubmodules ? true, deepClone ? false , branchName ? null -, sparseCheckout ? "" +, sparseCheckout ? [] , nonConeMode ? false , name ? urlToName url rev , # Shell code executed after the file has been fetched @@ -55,13 +55,16 @@ in */ assert deepClone -> leaveDotGit; -assert nonConeMode -> (sparseCheckout != ""); +assert nonConeMode -> !(sparseCheckout == "" || sparseCheckout == []); if md5 != "" then throw "fetchgit does not support md5 anymore, please use sha256" else if hash != "" && sha256 != "" then throw "Only one of sha256 or hash can be set" else +# Added 2022-11-12 +lib.warnIf (builtins.isString sparseCheckout) + "Please provide directories/patterns for sparse checkout as a list of strings. Support for passing a (multi-line) string is deprecated and will be removed in the next release." stdenvNoCC.mkDerivation { inherit name; builder = ./builder.sh; @@ -79,7 +82,12 @@ stdenvNoCC.mkDerivation { else lib.fakeSha256; - inherit url rev leaveDotGit fetchLFS fetchSubmodules deepClone branchName sparseCheckout nonConeMode postFetch; + # git-sparse-checkout(1) says: + # > When the --stdin option is provided, the directories or patterns are read + # > from standard in as a newline-delimited list instead of from the arguments. + sparseCheckout = if builtins.isString sparseCheckout then sparseCheckout else builtins.concatStringsSep "\n" sparseCheckout; + + inherit url rev leaveDotGit fetchLFS fetchSubmodules deepClone branchName nonConeMode postFetch; postHook = if netrcPhase == null then null else '' ${netrcPhase} |