nix icon indicating copy to clipboard operation
nix copied to clipboard

Lazy paths

Open roberth opened this issue 1 year ago • 7 comments

(This is #10252, but as an upstream branch for easier collaboration)

Motivation

Improve performance, and make the fetchTree interface more capable while keeping it clean.

Description

This makes fetchTree return lazy InputAccessor-based SourcePaths instead of "cowardly" fetching them to the store and returning absolute "system" paths. It stays close to existing path semantics, including support for readFile "${toString p}/..", which some expressions rely on. It does not go as far as lazy-trees, but judging from the amount of change I could reuse, and how little of my own I had to add, lazy-trees will be a natural extension of this PR.

Done:

  • Packages and NixOS evaluate as usual
    • no hash changes, based on my limited testing
  • Flake is not added to store unless e.g.
    • "${flake.outPath}"
    • uses module system (needs clever lazy source strings, or a change to the module system)
  • Note that the above is already an improvement over the status quo - always fetching to the store
  • iirc 0.1s reduction on nixpkgs#hello, and 1s reduction on nixosTests.simple

Conclusion so far: Viable

TODO:

  • [ ] Check the TODO and FIXMEs
  • [ ] Update the test suite
    • probably some intended behavior change, such as removal of narHash in some observable places
      • do we want to do that now? not sure
    • possibly finds a bug
  • [ ] Check performance again
  • [ ] Cherry-pick the toString path behavior to lazy-trees
  • [ ] Run flake-regressions in full to assess the breakage of changing (fetchTree x).outPath
  • [ ] Run flake-regressions in full to assess the breakage of changing flake.outPath

Context

Priorities and Process

Add :+1: to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

roberth avatar Aug 25 '24 08:08 roberth