-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Create (experimental) outputOf
primop.
#8813
Conversation
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.
Superficial review of draft.
src/libexpr/primops.cc
Outdated
will return a placeholder for the output of the output of `myDrv`, | ||
interpreted as a derivation. | ||
|
||
It may help to compare to the `->` operator in C, which can also by |
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.
Why not the .
operator in Nix?
I guess some distance may help, but it's not so great to assume knowledge of C.
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.
I removed that and referenced ^
in the CLI syntax for derived paths, which is what it actually corresponds to.
I don't think .
is so good because the field in some sense "already exists", attributes in the attribute set being strict and all. but talking about ^
side-steps that issue.
src/libexpr/primops.cc
Outdated
|
||
For instance, `builtins.outputOf (builtins.outputOf myDrv "out) "out"` | ||
will return a placeholder for the output of the output of `myDrv`, | ||
interpreted as a derivation. |
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.
Might be helpful to show what the process is for building the placeholder?
ie myDrv
produces a .drv
, which then produces a .drv
, which is then built to get the actual value for the placeholder.
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.
I expanded upon this, but I didn't really make this clear yet I don't think.
e1c3f03
to
368d213
Compare
outputOf
primop.outputOf
primop.
outputOf
primop.outputOf
primop.
87c3451
to
ecd4e6f
Compare
This choice of variable name makes it more clear what is going on. Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
`EvalState::mkSingleDerivedPathString` previously contained its own inverse (printing, rather than parsing) in order to validate what was parsed. Now that is pulled out into its own separate function: `EvalState::coerceToSingleDerivedPath`. In additional that pulled out logic is deduplicated with `EvalState::mkOutputString` via `EvalState::mkOutputStringRaw`, which is itself deduplicated (and generalized) with `DownstreamPlaceholder::mkOutputStringRaw`. All these changes make the unit tests simpler. (We would ideally write more unit tests for `mkSingleDerivedPathString` `coerceToSingleDerivedPath` directly, but we cannot yet do that because the IO in reading the store path won't work when the dummy store cannot hold anything. Someday we'll have a proper in-memory store which will work for this.) Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
1deeb74
to
11c9d8b
Compare
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.
I think I've suggested some broken English before.
7f24e8a
to
c089400
Compare
In the Nix language, given a drv path, we should be able to construct another string referencing to one of its output. We can do this today with `(import drvPath).output`, but this only works for derivations we already have. With dynamic derivations, however, that doesn't work well because the `drvPath` isn't yet built: importing it like would need to trigger IFD, when the whole point of this feature is to do "dynamic build graph" without IFD! Instead, what we want to do is create a placeholder value with the right string context to refer to the output of the as-yet unbuilt derivation. A new primop in the language, analogous to `builtins.placeholder` can be used to create one. This will achieve all the right properties. The placeholder machinery also will match out the `outPath` attribute for CA derivations works. In 60b7121 we added that type of placeholder, and the derived path and string holder changes necessary to support it. Then in the previous commit we cleaned up the code (inspiration finally hit me!) to deduplicate the code and expose exactly what we need. Now, we can wire up the primop trivally! Part of RFC 92: dynamic derivations (tracking issue NixOS#6316) Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
Jon - you rule, this sounds super useful |
Motivation
In the Nix language, given a drv path, we should be able to construct another string referencing to one of its output. We can do this today with
(import drvPath).output
, but this only works for derivations we already have.With dynamic derivations, however, that doesn't work well because the
drvPath
isn't yet built: importing it like would need to trigger IFD, when the whole point of this feature is to do "dynamic build graph" without IFD!Instead, what we want to do is create a placeholder value with the right string context to refer to the output of the as-yet unbuilt derivation. A new primop in the language, analogous to
builtins.placeholder
can be used to create one. This will achieve all the right properties. The placeholder machinery also will match out theoutPath
attribute for CA derivations works.Context
Probably best to review these two commits separately!
In 60b7121 we added that type of placeholder, and the derived path and string holder changes necessary to support it. Then in first commit of this PR we cleaned up the code (inspiration finally hit me!) to deduplicate the code and expose exactly. what we need. In the second commit we can wire up the primop trivally!
Part of RFC 92: dynamic derivations (tracking issue #6316)
Checklist for maintainers
Maintainers: tick if completed or explain if not relevant
tests/**.sh
src/*/tests
tests/nixos/*
Priorities
Add 👍 to pull requests you find important.