--max-jobs 0 should still build drvs with preferLocalBuild according to docs #855

Open
opened 2025-06-10 02:52:11 +00:00 by bacchanalia · 3 comments
Member

Describe the bug

The documentation for max-jobs states:

0 is useful when using remote builders to prevent any local builds (except for preferLocalBuild derivation attribute which executes locally regardless).

but contrary to the docs, derivations with preferLocalBuild set do not get built with --max-jobs 0

Steps To Reproduce

nix build --option substitute false --option builders '' --max-jobs 0 --impure --expr '(import ./. {}).writeText "preferLocalBuildWithMaxJobs0" ""'

Expected behavior

The above command succeeds.

nix --version output

nix (Lix, like Nix) 2.92.0

Additional context

I'm not sure if the documented behavior was ever actually the case, and the language is a but unclear, so I might be reading it wrong, but it would be very useful to have a setting to allow only building derivations with preferLocalBuild set. In some cases it may be desirable to disallow even those, so maybe ideally it should be a separate setting?

## Describe the bug The documentation for [max-jobs](https://docs.lix.systems/manual/lix/2.92/command-ref/conf-file.html?highlight=max-jobs#conf-max-jobs) states: > `0` is useful when using remote builders to prevent any local builds (except for `preferLocalBuild` derivation attribute which executes locally regardless). but contrary to the docs, derivations with `preferLocalBuild` set do not get built with `--max-jobs 0` ## Steps To Reproduce `nix build --option substitute false --option builders '' --max-jobs 0 --impure --expr '(import ./. {}).writeText "preferLocalBuildWithMaxJobs0" ""'` ## Expected behavior The above command succeeds. ## `nix --version` output `nix (Lix, like Nix) 2.92.0` ## Additional context I'm not sure if the documented behavior was ever actually the case, and the language is a but unclear, so I might be reading it wrong, but it would be very useful to have a setting to allow only building derivations with `preferLocalBuild` set. In some cases it may be desirable to disallow even those, so maybe ideally it should be a separate setting?
pennae added this to the 2.95 milestone 2025-12-01 14:51:31 +00:00
Owner

It's a pretty weird feature I must say, fortunately, it doesn't create a situation where preferLocalBuilds just consumes arbitrary amount of tokens EXCEPT if you pass max-jobs = 0 and your graph is ENTIRELY composed of preferLocalBuilds = true

It's a pretty weird feature I must say, fortunately, it doesn't create a situation where `preferLocalBuilds` just consumes arbitrary amount of tokens EXCEPT if you pass `max-jobs = 0` and your graph is ENTIRELY composed of `preferLocalBuilds = true`…
Member

This issue was mentioned on Gerrit on the following CLs:

  • commit message in cl/4698 ("libstore/build: allow preferLocalBuild = true to bypass max-jobs = 0")
<!-- GERRIT_LINKBOT: {"cls": [{"backlink": "https://gerrit.lix.systems/c/lix/+/4698", "number": 4698, "kind": "commit message"}], "cl_meta": {"4698": {"change_title": "libstore/build: allow `preferLocalBuild = true` to bypass `max-jobs = 0`"}}} --> This issue was mentioned on Gerrit on the following CLs: * commit message in [cl/4698](https://gerrit.lix.systems/c/lix/+/4698) ("libstore/build: allow `preferLocalBuild = true` to bypass `max-jobs = 0`")
Author
Member

The main use case for this is, I think, to be able to build configuration files but to fail early if there is a cache miss for an actual package. In that case not having a setting to control slots is probably fine, as long as you actually trust derivations marked with preferLocalBuild are cheap.

I think a more general solution, would be replace the concept of slots with more fine grained resources. Then you could set the defaults for preferLocalBuild vs not preferLocalBuild derivations separately. There are of course many design considerations for how to make such a system robust.

The main use case for this is, I think, to be able to build configuration files but to fail early if there is a cache miss for an actual package. In that case not having a setting to control slots is probably fine, as long as you actually trust derivations marked with preferLocalBuild are cheap. I think a more general solution, would be replace the concept of slots with more fine grained resources. Then you could set the defaults for preferLocalBuild vs not preferLocalBuild derivations separately. There are of course many design considerations for how to make such a system robust.
Sign in to join this conversation.
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lix-project/lix#855
No description provided.