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

Introduce DerivationOptions #12292

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Ericson2314
Copy link
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.


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
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
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
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.

* A value of `nullopt` indicates that the check is skipped.
* This means that there are no disallowed references.
*/
std::optional<Strings> disallowedReferences = std::nullopt;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
std::optional<Strings> disallowedReferences = std::nullopt;
Strings disallowedReferences = std::nullopt;

Depending on answer to the preceding question.

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

Copy link
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

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 <[email protected]>
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