Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add always-allow-substitutes #8047

Merged
merged 1 commit into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/manual/src/language/advanced-attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,9 @@ Derivations can declare some infrequently used optional attributes.
useful for very trivial derivations (such as `writeText` in Nixpkgs)
that are cheaper to build than to substitute from a binary cache.

You may disable the effects of this attibute by enabling the
`always-allow-substitutes` configuration option in Nix.

> **Note**
>
> You need to have a builder configured which satisfies the
Expand Down
8 changes: 8 additions & 0 deletions src/libstore/globals.hh
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,14 @@ public:
For the exact format and examples, see [the manual chapter on remote builds](../advanced-topics/distributed-builds.md)
)"};

Setting<bool> alwaysAllowSubstitutes{
this, false, "always-allow-substitutes",
R"(
If set to `true`, Nix will ignore the `allowSubstitutes` attribute in
derivations and always attempt to use available substituters.
For more information on `allowSubstitutes`, see [the manual chapter on advanced attributes](../language/advanced-attributes.md).
)"};

Setting<bool> buildersUseSubstitutes{
this, false, "builders-use-substitutes",
R"(
Expand Down
2 changes: 1 addition & 1 deletion src/libstore/parsed-derivations.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ bool ParsedDerivation::willBuildLocally(Store & localStore) const

bool ParsedDerivation::substitutesAllowed() const
{
return getBoolAttr("allowSubstitutes", true);
return settings.alwaysAllowSubstitutes ? true : getBoolAttr("allowSubstitutes", true);
Copy link
Member

Choose a reason for hiding this comment

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

This is really not a property of a "parsed derivation", but rather a property of the desired scheduling approach.
Not happy about that, but it's a structural problem, not a new thing.

}

bool ParsedDerivation::useUidRange() const
Expand Down
Loading