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

Add path primop. #1816

Merged
merged 1 commit into from Feb 7, 2018
Merged

Add path primop. #1816

merged 1 commit into from Feb 7, 2018

Conversation

shlevy
Copy link
Member

@shlevy shlevy commented Jan 25, 2018

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

@shlevy shlevy requested a review from edolstra January 25, 2018 15:08
@shlevy
Copy link
Member Author

shlevy commented Jan 25, 2018

Tested locally, will add tests and docs if this is deemed OK

@copumpkin
Copy link
Member

This is a new take on #1784, right?

@shlevy
Copy link
Member Author

shlevy commented Jan 26, 2018

Yep!

@shlevy shlevy mentioned this pull request Jan 26, 2018
@shlevy
Copy link
Member Author

shlevy commented Feb 1, 2018

Ping

@grahamc
Copy link
Member

grahamc commented Feb 1, 2018

@shlevy would you be able to write up a bit of docs for this function?

@shlevy
Copy link
Member Author

shlevy commented Feb 1, 2018

If it's otherwise acceptable yeah

exists at an arbitrary path. */
const auto path = expectedHash ?
path_ :
state.checkSourcePath(path_);
Copy link
Member

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.

@@ -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);
Copy link
Member

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.

@edolstra
Copy link
Member

edolstra commented Feb 6, 2018

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).
@shlevy shlevy changed the title Add addPath primop. Add path primop. Feb 6, 2018
@shlevy
Copy link
Member Author

shlevy commented Feb 6, 2018

@edolstra @grahamc Updated, added tests and docs.

@edolstra edolstra merged commit abe6be5 into NixOS:master Feb 7, 2018
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.

None yet

4 participants