Skip to content

perf?(core.wrapper): preferLocalBuild by default?#498

Draft
BirdeeHub wants to merge 1 commit intomainfrom
preferLocalBuild
Draft

perf?(core.wrapper): preferLocalBuild by default?#498
BirdeeHub wants to merge 1 commit intomainfrom
preferLocalBuild

Conversation

@BirdeeHub
Copy link
Copy Markdown
Owner

https://nix.dev/manual/nix/2.33/protocols/json/derivation/options.html#preferLocalBuild

This prevents it from checking a remote cache for your wrapper derivation with your settings in it.

Many wrapper derivation generators for various programs in nixpkgs and external flakes set this in their derivation, as the derivation contains user provided settings which will not be in a remote cache.

For the vast majority of wrapper derivations, the cost of checking the network should far exceed the amount of time it takes to link/copy/convert the files in the wrapper derivation.

If you have already built your wrapper derivation locally, it will still check your local cache.

@BirdeeHub BirdeeHub force-pushed the preferLocalBuild branch from b613968 to 1349048 Compare May 3, 2026 17:17
@zenoli
Copy link
Copy Markdown
Contributor

zenoli commented May 3, 2026

Under what circumstances would not preferring local builds be faster?

@BirdeeHub
Copy link
Copy Markdown
Owner Author

BirdeeHub commented May 3, 2026

It depends entirely on how heavy the build command is and how many substitutors you have

Linking a directory, and converting a couple json files to toml is almost certainly faster than hitting the network is.

Basically, if it is not marked as preferLocalBuild, it tries all your substitutors to try to find your wrapper derivation. It probably won't find it, because you have your own settings in there. Then it can start building.

As opposed to just checking your local drive and if it isnt there, starting the build.

This is especially noticeable when you have a slow network.

At least, in theory. I haven't adequately tested to see if this is actually significantly faster yet. It likely still checks the local disk first regardless, so it should only affect the first build of the module with a particular set of settings either way on a particular machine.

Building the actual program is almost certainly slower than checking the network is, barring the occasional simple script. But we are just making some links, and editing a few files

The thing I need to check is, would this make it harder to implement caching for tests later. If so, maybe not a good idea? Unsure though.

@BirdeeHub BirdeeHub marked this pull request as draft May 3, 2026 18:17
@BirdeeHub BirdeeHub changed the title perf(core.wrapper): preferLocalBuild by default perf?(core.wrapper): preferLocalBuild by default? May 3, 2026
@BirdeeHub BirdeeHub force-pushed the preferLocalBuild branch 2 times, most recently from bb81b4d to a7f6eba Compare May 9, 2026 12:45
https://nix.dev/manual/nix/2.33/protocols/json/derivation/options.html#preferLocalBuild

This prevents it from checking a remote cache for your wrapper
derivation with your settings in it.

Many wrapper derivation generators for various programs in nixpkgs and
external flakes set this in their derivation, as the derivation contains
user provided settings which will not be in a remote cache.

For the vast majority of wrapper derivations, the cost of checking the
network should far exceed the amount of time it takes to
link/copy/convert the files in the wrapper derivation.

If you have already built your wrapper derivation locally, it will still
check your local cache.
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.

2 participants