mirror of
https://github.com/NixOS/nix
synced 2025-06-25 06:31:14 +02:00
Add inputs.self.submodules
flake attribute
This allows a flake to specify that it needs Git submodules to be enabled (or disabled, if we ever change the default) on the top-level flake. This requires the input to be refetched, but since the first fetch is lazy, this shouldn't be expensive. Currently the only attribute allowed by `inputs.self` is `submodules`, but more can be added in the future (e.g. a `lazy` attribute to opt in to lazy tree behaviour). Fixes #5312, #9842.
This commit is contained in:
parent
01598487b7
commit
25fcc8d1ab
3 changed files with 128 additions and 48 deletions
|
@ -77,6 +77,20 @@ git -C "$rootRepo" commit -m "Add flake.nix"
|
|||
storePath=$(nix flake prefetch --json "$rootRepo?submodules=1" | jq -r .storePath)
|
||||
[[ -e "$storePath/submodule" ]]
|
||||
|
||||
# Test the use of inputs.self.
|
||||
cat > "$rootRepo"/flake.nix <<EOF
|
||||
{
|
||||
inputs.self.submodules = true;
|
||||
outputs = { self }: {
|
||||
foo = self.outPath;
|
||||
};
|
||||
}
|
||||
EOF
|
||||
git -C "$rootRepo" commit -a -m "Bla"
|
||||
|
||||
storePath=$(nix eval --raw "$rootRepo#foo")
|
||||
[[ -e "$storePath/submodule" ]]
|
||||
|
||||
# The root repo may use the submodule repo as an input
|
||||
# through the relative path. This may change in the future;
|
||||
# see: https://discourse.nixos.org/t/57783 and #9708.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue