Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/nix/flake-prefetch-inputs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ struct CmdFlakePrefetchInputs : FlakeCommand
return;

if (auto lockedNode = dynamic_cast<const LockedNode *>(&node)) {
if (lockedNode->buildTime)
return;
try {
Activity act(*logger, lvlInfo, actUnknown, fmt("fetching '%s'", lockedNode->lockedRef));
auto accessor = lockedNode->lockedRef.input.getAccessor(store).first;
Expand Down
2 changes: 1 addition & 1 deletion src/nix/flake-prefetch-inputs.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ R""(

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

This operation is recursive: it will fetch not just the direct inputs of the top-level flake, but also transitive inputs.
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`.

)""
25 changes: 25 additions & 0 deletions tests/functional/flakes/build-time-flake-inputs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,28 @@ rm -rf "$lazy"
clearStore

expectStderr 1 nix build --out-link "$TEST_ROOT/result" -L "$repo" | grepQuiet "Cannot build.*source.drv"

# `nix flake prefetch-inputs` should ignore build-time inputs.
depDir=$TEST_ROOT/dep
createGitRepo "$depDir"
createSimpleGitFlake "$depDir"

cat > "$repo/flake.nix" <<EOF
{
inputs.lazy = {
type = "git";
url = "file://$depDir";
buildTime = true;
};

outputs = { self, ... }: { };
}
EOF

nix flake lock "$repo"

clearStore
rm -rf "$TEST_HOME/.cache"
rm -rf "$depDir"

nix flake prefetch-inputs "$repo"