Skip to content

nix flake prefetch-inputs: Add#127

Merged
edolstra merged 4 commits intodetsys-mainfrom
eelcodolstra/fh-865-add-nix-flake-prefetch-inputs-command-to-fetch-inputs-in
Jun 30, 2025
Merged

nix flake prefetch-inputs: Add#127
edolstra merged 4 commits intodetsys-mainfrom
eelcodolstra/fh-865-add-nix-flake-prefetch-inputs-command-to-fetch-inputs-in

Conversation

@edolstra
Copy link
Copy Markdown
Collaborator

Motivation

This command fetches all inputs of a flake in parallel. This can be a lot faster than the serialized on-demand fetching during regular flake evaluation. The downside is that it may fetch inputs that aren't normally used.

Example runtime for

$ chmod -R u+w /tmp/nix2; rm -rf /tmp/nix2; rm ~/.cache/nix/fetcher-cache-v3.sqlite*; rm -rf ~/.cache/nix/tarball-cache/ ~/.cache/nix/gitv3/; time nix flake prefetch-inputs --store /tmp/nix2 https://api.flakehub.com/f/pinned/informalsystems/cosmos.nix/0.3.0/018ce9ed-d0be-7ce5-81b6-a3c6e3ae1187/source.tar.gz

with http-connections = 1:

real    4m11.859s
user    2m6.931s
sys     0m25.619s

and http-connections = 25 (the default):

real    0m57.146s
user    2m49.506s
sys     0m36.008s

Context

edolstra added 3 commits June 24, 2025 15:30
This command fetches all inputs of a flake in parallel.

Example runtime for

  $ chmod -R u+w /tmp/nix2; rm -rf /tmp/nix2; rm ~/.cache/nix/fetcher-cache-v3.sqlite*; rm -rf ~/.cache/nix/tarball-cache/ ~/.cache/nix/gitv3/; time nix flake prefetch-inputs --store /tmp/nix2 https://api.flakehub.com/f/pinned/informalsystems/cosmos.nix/0.3.0/018ce9ed-d0be-7ce5-81b6-a3c6e3ae1187/source.tar.gz

with http-connections = 1:

real    4m11.859s
user    2m6.931s
sys     0m25.619s

and http-connections = 25 (the default):

real    0m57.146s
user    2m49.506s
sys     0m36.008s
…h-865-add-nix-flake-prefetch-inputs-command-to-fetch-inputs-in
…mmands

This allows us to start splitting up src/nix/flake.cc.
Copy link
Copy Markdown
Member

@cole-h cole-h left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as advertised on the tin.

@edolstra edolstra added this pull request to the merge queue Jun 30, 2025
Merged via the queue into detsys-main with commit 4235165 Jun 30, 2025
32 checks passed
@edolstra edolstra deleted the eelcodolstra/fh-865-add-nix-flake-prefetch-inputs-command-to-fetch-inputs-in branch June 30, 2025 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants