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
nix: allow using --file - to read from stdin #2583
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.
Some nits while reading through, although in the end I think are out of scope for this PR. Sorry for the noise, but leaving in case helpful or folks want to discuss :). Will 'resolve' if seem less suitable by the end.
Only other suggestion would be to add a test or three for this welcome new functionality! 👍
src/libexpr/eval.cc
Outdated
addErrorPrefix(e, "while evaluating %1%:\n", "<stdin>"); | ||
throw; | ||
} | ||
} else { |
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.
The new indent level perhaps could be avoided with an early return? Suggesting to avoid noise it causes, not sure what general preference on that point is stylistically.
Concretely, perhaps drop the else { }
and add a return at the end of the if {}
or perhaps return eval(e, v)
within the try {}
?
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.
not sure what style is preferred, happy to change it if desired
src/libexpr/eval.cc
Outdated
|
||
FileEvalCache::iterator i; |
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.
Pre-existing problem, but while looking through this... declaring these temporaries in the conditional seems to solve obvious scoping problems currently resolved by using variable names like path2
for temporaries later in the sequence... depending on auto
preferences it'd look like this:
(EDIT: just kidding, looks like a clean solution for this requires c++17 maybe? (if (auto i = fileEvalCache.find(path); i != fileEvalCache.end())
))
(I can't mark them resolved since they're comments! D'oh. Sorry about that :)) |
Brings the `nix-instantiate -` functionality to all the new nix commands that take the --file argument. $ echo '{ foo = 1 + 1; }' | nix eval -f - foo 2
@dtzWill I dismissed some of the comments, most of them where about existing code that I just indented. |
Reading from stdin is only allowed for specific cli arguments, make sure this isn't accidentally possible in expressions.
I marked this as stale due to inactivity. → More info |
can be closed |
Brings the
nix-instantiate -
functionality to all the new nix commands that take the --file argument.