Skip to content

Introduce DerivationOptions#12292

Merged
Ericson2314 merged 1 commit intoNixOS:masterfrom
obsidiansystems:derivation-options
Feb 17, 2025
Merged

Introduce DerivationOptions#12292
Ericson2314 merged 1 commit intoNixOS:masterfrom
obsidiansystems:derivation-options

Conversation

@Ericson2314
Copy link
Copy Markdown
Member

@Ericson2314 Ericson2314 commented Jan 20, 2025

Motivation

See the Doxygen for details.

Thanks to these changes, we are able to drastically restrict how the rest of the code-base uses ParseDerivation.

Context

This is a first step towards PR #10760, and the issues it addresses.

Progress on #9846


Add 👍 to pull requests you find important.

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

CC @haenoe, who co-authored this.

@Ericson2314 Ericson2314 requested a review from edolstra as a code owner January 20, 2025 06:43
@Ericson2314 Ericson2314 force-pushed the derivation-options branch 3 times, most recently from 3555ae5 to 6b6529b Compare January 20, 2025 15:12
Copy link
Copy Markdown
Member

@roberth roberth left a comment

Choose a reason for hiding this comment

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

I like the idea, but I haven't reviewed thoroughly for correctness

* format), we have the option of instead storing the options
* separately. That would be nice to separate concerns, and not make any
* environment variable names magical.
*/
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is it meant to be a lossless representation of part of the derivation, or is it supposed to represent part of the derivation semantically uniquely?

Copy link
Copy Markdown
Member Author

@Ericson2314 Ericson2314 Jan 20, 2025

Choose a reason for hiding this comment

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

Ah yes it is supposed to reflect the semantics, not the syntax.

In other words, there will not be a DerivationOptions -> Env function; instead, the ATerm logic will (eventually):

  1. Check that the options are implied by the rest of the Derivation
  2. Since the check passed, safely ignore the (eventual new) DerivationOptions options; field of the derivation as superfluous
  3. Serialize as today

So yes let's do these changes.

Comment on lines -2866 to -2882
struct Checks
{
bool ignoreSelfRefs = false;
std::optional<uint64_t> maxSize, maxClosureSize;
std::optional<Strings> allowedReferences, allowedRequisites, disallowedReferences, disallowedRequisites;
};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice

@nixos-discourse
Copy link
Copy Markdown

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2024-01-20-nix-team-meeting-minutes-209/59119/1

This is a first step towards PR NixOS#10760, and the issues it addresses.
See the Doxygen for details.

Thanks to these changes, we are able to drastically restrict how the
rest of the code-base uses `ParseDerivation`.

Co-Authored-By: HaeNoe <git@haenoe.party>
Copy link
Copy Markdown
Member

@roberth roberth left a comment

Choose a reason for hiding this comment

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

Added some more thoughts. Nice work

* format cannot change, but in alternatives to it (like the JSON
* format), we have the option of instead storing the options
* separately. That would be nice to separate concerns, and not make any
* environment variable names magical.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

(no action required)
Another use case is that on darwin, we've run out of environment variable space at times in the haskell builders. Removing unnecessary envs helps a bit with those scenarios too.

Comment on lines +184 to +185
JSON_IMPL(DerivationOptions);
JSON_IMPL(DerivationOptions::OutputChecks)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

JSON_IMPL only has declarations.
Tripped me up for a sec.
No action required in this PR.

* not needed (attributes are not passed through the environment, so
* there is no size constraint).
*/
StringSet passAsFile;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This could perhaps be generalized to std::map<> from environment variable name to file contents (or file creation "commands"), where the ATerm parser is responsible for applying the current semantics.
Could be done in a follow-up.

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