summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWinter <winter@winter.cafe>2022-08-04 15:26:03 -0400
committerRick van Schijndel <Mindavi@users.noreply.github.com>2022-08-14 23:03:07 +0200
commitdbd18a63a7e8bb59efa9e556241786ac2169033a (patch)
treedf645807f0065b6c3d21ac78cba20406b7fa27e5
parent989b7550e6f2b65230f64233a0216cce4ec6ddf8 (diff)
fetchgit: allow disabling cone mode for sparse checkouts, fix test
-rw-r--r--doc/builders/fetchers.chapter.md6
-rw-r--r--nixos/doc/manual/from_md/release-notes/rl-2211.section.xml12
-rw-r--r--nixos/doc/manual/release-notes/rl-2211.section.md2
-rw-r--r--pkgs/build-support/fetchgit/builder.sh1
-rw-r--r--pkgs/build-support/fetchgit/default.nix4
-rwxr-xr-xpkgs/build-support/fetchgit/nix-prefetch-git4
-rw-r--r--pkgs/build-support/fetchgit/tests.nix12
7 files changed, 36 insertions, 5 deletions
diff --git a/doc/builders/fetchers.chapter.md b/doc/builders/fetchers.chapter.md
index 947afe8e9fdb..12d8a5d887fd 100644
--- a/doc/builders/fetchers.chapter.md
+++ b/doc/builders/fetchers.chapter.md
@@ -91,7 +91,7 @@ Used with Git. Expects `url` to a Git repo, `rev`, and `sha256`. `rev` in this c
Additionally, the following optional arguments can be given: `fetchSubmodules = true` makes `fetchgit` also fetch the submodules of a repository. If `deepClone` is set to true, the entire repository is cloned as opposing to just creating a shallow clone. `deepClone = true` also implies `leaveDotGit = true` which means that the `.git` directory of the clone won't be removed after checkout.
-If only parts of the repository are needed, `sparseCheckout` can be used. This will prevent git from fetching unnecessary blobs from server, see [git sparse-checkout](https://git-scm.com/docs/git-sparse-checkout) and [git clone --filter](https://git-scm.com/docs/git-clone#Documentation/git-clone.txt---filterltfilter-specgt) for more information:
+If only parts of the repository are needed, `sparseCheckout` can be used. This will prevent git from fetching unnecessary blobs from server, see [git sparse-checkout](https://git-scm.com/docs/git-sparse-checkout) for more information:
```nix
{ stdenv, fetchgit }:
@@ -101,8 +101,8 @@ stdenv.mkDerivation {
src = fetchgit {
url = "https://...";
sparseCheckout = ''
- path/to/be/included
- another/path
+ directory/to/be/included
+ another/directory
'';
sha256 = "0000000000000000000000000000000000000000000000000000";
};
diff --git a/nixos/doc/manual/from_md/release-notes/rl-2211.section.xml b/nixos/doc/manual/from_md/release-notes/rl-2211.section.xml
index 383c9d8a04cd..b5c3df14e45a 100644
--- a/nixos/doc/manual/from_md/release-notes/rl-2211.section.xml
+++ b/nixos/doc/manual/from_md/release-notes/rl-2211.section.xml
@@ -253,6 +253,18 @@
</listitem>
<listitem>
<para>
+ The <literal>fetchgit</literal> fetcher now uses
+ <link xlink:href="https://www.git-scm.com/docs/git-sparse-checkout/2.37.0#_internalscone_mode_handling">cone
+ mode</link> by default for sparse checkouts.
+ <link xlink:href="https://www.git-scm.com/docs/git-sparse-checkout/2.37.0#_internalsnon_cone_problems">Non-cone
+ mode</link> can be enabled by passing
+ <literal>nonConeMode = true</literal>, but note that non-cone
+ mode is deprecated and this option may be removed alongside a
+ future Git update without notice.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
<literal>bsp-layout</literal> no longer uses the command
<literal>cycle</literal> to switch to other window layouts, as
it got replaced by the commands <literal>previous</literal>
diff --git a/nixos/doc/manual/release-notes/rl-2211.section.md b/nixos/doc/manual/release-notes/rl-2211.section.md
index 53daf9544634..1e37922f7b23 100644
--- a/nixos/doc/manual/release-notes/rl-2211.section.md
+++ b/nixos/doc/manual/release-notes/rl-2211.section.md
@@ -97,6 +97,8 @@ In addition to numerous new and upgraded packages, this release has the followin
- The `isPowerPC` predicate, found on `platform` attrsets (`hostPlatform`, `buildPlatform`, `targetPlatform`, etc) has been removed in order to reduce confusion. The predicate was was defined such that it matches only the 32-bit big-endian members of the POWER/PowerPC family, despite having a name which would imply a broader set of systems. If you were using this predicate, you can replace `foo.isPowerPC` with `(with foo; isPower && is32bit && isBigEndian)`.
+- The `fetchgit` fetcher now uses [cone mode](https://www.git-scm.com/docs/git-sparse-checkout/2.37.0#_internalscone_mode_handling) by default for sparse checkouts. [Non-cone mode](https://www.git-scm.com/docs/git-sparse-checkout/2.37.0#_internalsnon_cone_problems) can be enabled by passing `nonConeMode = true`, but note that non-cone mode is deprecated and this option may be removed alongside a future Git update without notice.
+
- `bsp-layout` no longer uses the command `cycle` to switch to other window layouts, as it got replaced by the commands `previous` and `next`.
- The Barco ClickShare driver/client package `pkgs.clickshare-csc1` and the option `programs.clickshare-csc1.enable` have been removed,
diff --git a/pkgs/build-support/fetchgit/builder.sh b/pkgs/build-support/fetchgit/builder.sh
index c7c7d21709a1..66b6c168e41d 100644
--- a/pkgs/build-support/fetchgit/builder.sh
+++ b/pkgs/build-support/fetchgit/builder.sh
@@ -12,6 +12,7 @@ $SHELL $fetcher --builder --url "$url" --out "$out" --rev "$rev" \
${deepClone:+--deepClone} \
${fetchSubmodules:+--fetch-submodules} \
${sparseCheckout:+--sparse-checkout "$sparseCheckout"} \
+ ${nonConeMode:+--non-cone-mode} \
${branchName:+--branch-name "$branchName"}
runHook postFetch
diff --git a/pkgs/build-support/fetchgit/default.nix b/pkgs/build-support/fetchgit/default.nix
index 84f2278db299..f516c3d5a03b 100644
--- a/pkgs/build-support/fetchgit/default.nix
+++ b/pkgs/build-support/fetchgit/default.nix
@@ -16,6 +16,7 @@ in
, fetchSubmodules ? true, deepClone ? false
, branchName ? null
, sparseCheckout ? ""
+, nonConeMode ? false
, name ? urlToName url rev
, # Shell code executed after the file has been fetched
# successfully. This can do things like check or transform the file.
@@ -54,6 +55,7 @@ in
*/
assert deepClone -> leaveDotGit;
+assert nonConeMode -> (sparseCheckout != "");
if md5 != "" then
throw "fetchgit does not support md5 anymore, please use sha256"
@@ -77,7 +79,7 @@ stdenvNoCC.mkDerivation {
else
lib.fakeSha256;
- inherit url rev leaveDotGit fetchLFS fetchSubmodules deepClone branchName sparseCheckout postFetch;
+ inherit url rev leaveDotGit fetchLFS fetchSubmodules deepClone branchName sparseCheckout nonConeMode postFetch;
postHook = if netrcPhase == null then null else ''
${netrcPhase}
diff --git a/pkgs/build-support/fetchgit/nix-prefetch-git b/pkgs/build-support/fetchgit/nix-prefetch-git
index 4e6f25b8dd7d..9c2048066ce4 100755
--- a/pkgs/build-support/fetchgit/nix-prefetch-git
+++ b/pkgs/build-support/fetchgit/nix-prefetch-git
@@ -49,6 +49,7 @@ Options:
--hash h Expected hash.
--branch-name Branch name to check out into
--sparse-checkout Only fetch and checkout part of the repository.
+ --non-cone-mode Use non-cone mode for sparse checkouts.
--deepClone Clone the entire repository.
--no-deepClone Make a shallow clone of just the required ref.
--leave-dotGit Keep the .git directories.
@@ -77,6 +78,7 @@ for arg; do
--branch-name) argfun=set_branchName;;
--deepClone) deepClone=true;;
--sparse-checkout) argfun=set_sparseCheckout;;
+ --non-cone-mode) nonConeMode=true;;
--quiet) QUIET=true;;
--no-deepClone) deepClone=;;
--leave-dotGit) leaveDotGit=true;;
@@ -116,7 +118,7 @@ init_remote(){
clean_git remote add origin "$url"
if [ -n "$sparseCheckout" ]; then
git config remote.origin.partialclonefilter "blob:none"
- echo "$sparseCheckout" | git sparse-checkout set --stdin
+ echo "$sparseCheckout" | git sparse-checkout set --stdin ${nonConeMode:+--no-cone}
fi
( [ -n "$http_proxy" ] && clean_git config http.proxy "$http_proxy" ) || true
}
diff --git a/pkgs/build-support/fetchgit/tests.nix b/pkgs/build-support/fetchgit/tests.nix
index b9ab66d9353c..62fe3f77bbdd 100644
--- a/pkgs/build-support/fetchgit/tests.nix
+++ b/pkgs/build-support/fetchgit/tests.nix
@@ -16,6 +16,18 @@
src
tests
'';
+ sha256 = "sha256-g1PHGTWgAcd/+sXHo1o6AjVWCvC6HiocOfMbMh873LQ=";
+ };
+
+ sparseCheckoutNonConeMode = testers.invalidateFetcherByDrvHash fetchgit {
+ name = "nix-source";
+ url = "https://github.com/NixOS/nix";
+ rev = "9d9dbe6ed05854e03811c361a3380e09183f4f4a";
+ sparseCheckout = ''
+ src
+ tests
+ '';
+ nonConeMode = true;
sha256 = "sha256-FknO6C/PSnMPfhUqObD4vsW4PhkwdmPa9blNzcNvJQ4=";
};
}