-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
nix repl: load flakes from cli args #5824
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -611,11 +611,11 @@ void NixRepl::loadFile(const Path & path) | |||||||||||||||
|
|
||||||||||||||||
| void NixRepl::loadFlake(const std::string & flakeRefS) | ||||||||||||||||
| { | ||||||||||||||||
| auto flakeRef = parseFlakeRef(flakeRefS, absPath("."), true); | ||||||||||||||||
| auto [flakeRef, fragment] = parseFlakeRefWithFragment(flakeRefS, absPath("."), true); | ||||||||||||||||
| if (evalSettings.pureEval && !flakeRef.input.isImmutable()) | ||||||||||||||||
| throw Error("cannot use ':load-flake' on mutable flake reference '%s' (use --impure to override)", flakeRefS); | ||||||||||||||||
|
|
||||||||||||||||
| Value v; | ||||||||||||||||
| auto v = state->allocValue(); | ||||||||||||||||
|
|
||||||||||||||||
| flake::callFlake(*state, | ||||||||||||||||
| flake::lockFlake(*state, flakeRef, | ||||||||||||||||
|
|
@@ -624,8 +624,17 @@ void NixRepl::loadFlake(const std::string & flakeRefS) | |||||||||||||||
| .useRegistries = !evalSettings.pureEval, | ||||||||||||||||
| .allowMutable = !evalSettings.pureEval, | ||||||||||||||||
| }), | ||||||||||||||||
| v); | ||||||||||||||||
| addAttrsToScope(v); | ||||||||||||||||
| *v); | ||||||||||||||||
|
|
||||||||||||||||
| auto f = v->attrs->get(state->symbols.create(fragment)); | ||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this won’t work properly if
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll give that a shot. While we are at it, is there a function or method somewhere used to traverse the multiple outputs to find a match? |
||||||||||||||||
|
|
||||||||||||||||
| if (f == 0) { | ||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||
| warn("no attribute %s, nothing loaded", fragment); | ||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||
| return; | ||||||||||||||||
| }; | ||||||||||||||||
|
|
||||||||||||||||
| fragment != "" ? addAttrsToScope(*f->value) : addAttrsToScope(*v); | ||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||
|
|
||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
|
|
@@ -654,7 +663,10 @@ void NixRepl::reloadFiles() | |||||||||||||||
| if (!first) notice(""); | ||||||||||||||||
| first = false; | ||||||||||||||||
| notice("Loading '%1%'...", i); | ||||||||||||||||
| loadFile(i); | ||||||||||||||||
|
|
||||||||||||||||
| settings.isExperimentalFeatureEnabled(Xp::Flakes) | ||||||||||||||||
| ? loadFlake(i) | ||||||||||||||||
| : loadFile(i); | ||||||||||||||||
|
Comment on lines
+667
to
+669
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
since it's not really idiomatic in C++ (IMHO) to have the conditional operator at statement level. |
||||||||||||||||
| } | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
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.
What’s the reason for the change? Having
vas a plain stack-allocatedValueis nice since it has a lexical lifetime.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.
Oh I think I copied that from somewhere else while try to debug a stack overflow. I'll change it back 👍