about summary refs log tree commit diff
path: root/doc/builders
diff options
context:
space:
mode:
authorZhong Jianxin <azuwis@gmail.com>2021-09-08 10:33:50 +0800
committerZhong Jianxin <azuwis@gmail.com>2022-01-24 11:23:56 +0800
commit8c26b2d60f971f3e9f827039913b179c722618f5 (patch)
tree64826b555ca1a00934cbb427f3142b5b17b45a9d /doc/builders
parentd03a07d5a74ef780b9de78225a7d7d59db8f9169 (diff)
fetchgit: Add document for sparseCheckout
Diffstat (limited to 'doc/builders')
-rw-r--r--doc/builders/fetchers.chapter.md18
1 files changed, 18 insertions, 0 deletions
diff --git a/doc/builders/fetchers.chapter.md b/doc/builders/fetchers.chapter.md
index 5b28b2dcb398a..28388ba685d8f 100644
--- a/doc/builders/fetchers.chapter.md
+++ b/doc/builders/fetchers.chapter.md
@@ -40,6 +40,24 @@ 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 infomation:
+
+```nix
+{ stdenv, fetchgit }:
+
+stdenv.mkDerivation {
+  name = "hello";
+  src = fetchgit {
+    url = "https://...";
+    sparseCheckout = ''
+      path/to/be/included
+      another/path
+    '';
+    sha256 = "0000000000000000000000000000000000000000000000000000";
+  };
+}
+```
+
 ## `fetchfossil` {#fetchfossil}
 
 Used with Fossil. Expects `url` to a Fossil archive, `rev`, and `sha256`.