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
Add path primop. #1816
Add path primop. #1816
Conversation
Tested locally, will add tests and docs if this is deemed OK |
This is a new take on #1784, right? |
Yep! |
Ping |
@shlevy would you be able to write up a bit of docs for this function? |
If it's otherwise acceptable yeah |
src/libexpr/primops.cc
Outdated
exists at an arbitrary path. */ | ||
const auto path = expectedHash ? | ||
path_ : | ||
state.checkSourcePath(path_); |
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 looks wrong. In --restricted-eval
, the path should be checked even if a hash is given. In --pure-eval
, the path doesn't need to be checked but it requires a hash.
src/libexpr/primops.cc
Outdated
@@ -2071,6 +2129,7 @@ void EvalState::createBaseEnv() | |||
addPrimOp("__fromJSON", 1, prim_fromJSON); | |||
addPrimOp("__toFile", 2, prim_toFile); | |||
addPrimOp("__filterSource", 2, prim_filterSource); | |||
addPrimOp("__addPath", 1, prim_addPath); |
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'm not a fan of the name addPath
(add to what?). Maybe it should just be builtins.path
? That has a less imperative ring to it.
Looks good apart from 2 comments. |
builtins.path allows specifying the name of a path (which makes paths with store-illegal names now addable), allows adding paths with flat instead of recursive hashes, allows specifying a filter (so is a generalization of filterSource), and allows specifying an expected hash (enabling safe path adding in pure mode).
buiiltins.path allows specifying the name of a path (which makes paths
with store-illegal names now addable), allows adding paths with flat
instead of recursive hashes, allows specifying a filter (so is a
generalization of filterSource), and allows specifying an expected
hash (enabling safe path adding in pure mode).