From d9c33be3ddadebcdb1b5579d4e15bae25c26476a Mon Sep 17 00:00:00 2001 From: a-kenji Date: Tue, 29 Jul 2025 22:59:14 +0200 Subject: [PATCH] docs: Add `self-attribute` documentation (cherry picked from commit 937780ea08674a37bd70ab92fce2642ab1e4371a) --- src/nix/flake.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/nix/flake.md b/src/nix/flake.md index 6cb39fd5f..950b9fa4f 100644 --- a/src/nix/flake.md +++ b/src/nix/flake.md @@ -573,6 +573,27 @@ The value of the `follows` attribute is a `/`-separated sequence of input names denoting the path of inputs to be followed from the root flake. +## Self-attributes + +Flakes can declare attributes about themselves that affect how they are fetched. +These attributes are specified using the special `self` input and are retroactively +applied to it: + +```nix +{ + inputs.self.submodules = true; + inputs.self.lfs = true; +} +``` + +The following self-attributes are supported: + +* `submodules`: A Boolean denoting whether Git submodules should be fetched when this flake is used as an input. When set to `true`, Git submodules will be automatically fetched without requiring callers to specify `submodules=1` in the flake reference URL. Defaults to `false`. + +* `lfs`: A Boolean denoting whether Git LFS (Large File Storage) files should be fetched when this flake is used as an input. When set to `true`, Git LFS files will be automatically fetched. Defaults to `false`. + +These self-attributes eliminate the need for consumers of your flake to manually specify fetching options in their flake references. + Overrides and `follows` can be combined, e.g. ```nix