Skip to content

Commit f5e7146

Browse files
authored
Merge pull request #263 from DeterminateSystems/eelcodolstra/fh-994-make-nix-flake-prefetch-inputs-ignore-build-time-inputs
nix flake prefetch-inputs: Skip build-time inputs
2 parents d7ff2fe + dc4f411 commit f5e7146

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

src/nix/flake-prefetch-inputs.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ struct CmdFlakePrefetchInputs : FlakeCommand
4444
return;
4545

4646
if (auto lockedNode = dynamic_cast<const LockedNode *>(&node)) {
47+
if (lockedNode->buildTime)
48+
return;
4749
try {
4850
Activity act(*logger, lvlInfo, actUnknown, fmt("fetching '%s'", lockedNode->lockedRef));
4951
auto accessor = lockedNode->lockedRef.input.getAccessor(fetchSettings, store).first;

src/nix/flake-prefetch-inputs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ R""(
1212

1313
Fetch the inputs of a flake. This ensures that they are already available for any subsequent evaluation of the flake.
1414

15-
This operation is recursive: it will fetch not just the direct inputs of the top-level flake, but also transitive inputs.
15+
This operation is recursive: it fetches not just the direct inputs of the top-level flake, but also transitive inputs. It skips build-time inputs, i.e. inputs that have the attribute `buildTime = true`.
1616

1717
)""

tests/functional/flakes/build-time-flake-inputs.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,28 @@ rm -rf "$lazy"
6161
clearStore
6262

6363
expectStderr 1 nix build --out-link "$TEST_ROOT/result" -L "$repo" | grepQuiet "Cannot build.*source.drv"
64+
65+
# `nix flake prefetch-inputs` should ignore build-time inputs.
66+
depDir=$TEST_ROOT/dep
67+
createGitRepo "$depDir"
68+
createSimpleGitFlake "$depDir"
69+
70+
cat > "$repo/flake.nix" <<EOF
71+
{
72+
inputs.lazy = {
73+
type = "git";
74+
url = "file://$depDir";
75+
buildTime = true;
76+
};
77+
78+
outputs = { self, ... }: { };
79+
}
80+
EOF
81+
82+
nix flake lock "$repo"
83+
84+
clearStore
85+
rm -rf "$TEST_HOME/.cache"
86+
rm -rf "$depDir"
87+
88+
nix flake prefetch-inputs "$repo"

0 commit comments

Comments
 (0)