Nix flake inputs not lazy

Internally, Nix does something along the lines of

result = flake.outputs inputs;
inputs =
  mapAttrs
    (name: lockItem: fetchTree lockItem)
    lockedInputs;

Values in an attribute set are computed lazily, so as long as you don’t use the value of an input, the input does not need to be fetched during evaluation.

If your flake isn’t locked or if the lock file needs to be updated because you’ve changed the inputs, you’re doing more than evaluation though, so maybe that could explain what you’re seeing. Otherwise, --show-trace might give a clue as to why your expression does load the input. Maybe you’re using a framework that scans the inputs for some attribute. That’s one way to kill the lazy fetching.

Lazy trees / Source tree abstraction does not change this behavior. It only makes the unpacking lazy. Accessing any single file inside an input (think flake.nix) will be enough to cause the whole input to be downloaded, but not necessarily written to the store.