-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Parse deriving paths in DerivationOptions
#14506
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
base: master
Are you sure you want to change the base?
Parse deriving paths in DerivationOptions
#14506
Conversation
b126d79 to
00d2bf9
Compare
|
Ah it needs a daemon-version thing for that message. |
| bool ignoreSelfRefs = false; | ||
| std::optional<uint64_t> maxSize, maxClosureSize; | ||
|
|
||
| using DrvRef = nix::DrvRef<Input>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already giving me a headache... What is a DrvRef conceptually, and since when do output checks refer to anything other than store paths?
| * separately. That would be nice to separate concerns, and not make any | ||
| * environment variable names magical. | ||
| */ | ||
| template<typename Input> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Input is a heavily overloaded term. What's the intended meaning of input here?
|
|
||
| /** | ||
| * A reference is either to a to-be-registered output (by name), | ||
| * or to an already-registered store object (by `Input`). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't Input be named StorePath then? And why does that need to be a template parameter?
|
🎉 All dependencies have been resolved ! |
00d2bf9 to
4611d31
Compare
This is an example of "Parse, don't validate" principle [1]. Before, we had a number of `StringSet`s in `DerivationOptions` that were not *actually* allowed to be arbitrary sets of strings. Instead, each set member had to be one of: - a store path - a CA "downstream placeholder" - an output name Only later, in the code that checks outputs, would these strings be further parsed to match these cases. (Actually, only 2 by that point, because the placeholders must be rewritten away by then.) Now, we fully parse everything up front, and have an "honest" data type that reflects these invariants: - store paths are parsed, stored as (opaque) deriving paths - CA "downstream placeholders" are rewritten to the output deriving paths they denote - output names are the only arbitrary strings left Since the first two cases both become deriving paths, that leaves us with a `std::variant<SingleDerivedPath, String>` data type, which we use in our sets instead. Getting rid of placeholders is especially nice because we are replacing them with something much more internally-structured / transparent. [1]: https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-validate/ Co-authored-by: Sergei Zimmerman <[email protected]>
4611d31 to
81921d7
Compare
Motivation
This is an example of "Parse, don't validate" principle.
Before, we had a number of
StringSets inDerivationOptionsthat were not actually allowed to be arbitrary sets of strings. Instead, each set member had to be one of:a store path
a CA "downstream placeholder"
an output name
Only later, in the code that checks outputs, would these strings be further parsed to match these cases. (Actually, only 2 by that point, because the placeholders must be rewritten away by then.)
Now, we fully parse everything up front, and have an "honest" data type that reflects these invariants:
store paths are parsed, stored as (opaque) deriving paths
CA "downstream placeholders" are rewritten to the output deriving
paths they denote
output names are the only arbitrary strings left
Since the first two cases both become deriving paths, that leaves us with a
std::variant<SingleDerivedPath, String>data type, which we use in our sets instead.Getting rid of placeholders is especially nice because we are replacing them with something much more internally-structured / transparent.
Context
Progress on #13570
Depends on #14505
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.