Conversation
8309301 to
a9a5b85
Compare
d0145b8 to
c60e350
Compare
|
n.b. I think we should consider this:
|
|
|
||
| for (auto & [i,what] : getValues()) { | ||
| notice("Loading Installable '%1%'...", what); | ||
| addAttrsToScope(*i); |
There was a problem hiding this comment.
So this effectively merges the attributes of multiple installables?
I don't like that "loadables" are loaded into the global scope anyway. It makes discovering which attributes exist harder than it should.
Perhaps flakes and installables could be put in a binding that's derived from the installable name?
# nix repl nixpkgs
Loading Installable 'flake:nixpkgs#'...
Added 1 variable.
nix-repl> nixpkgs.legacyPackages.x86_64-linux.emacs.name
"emacs-27.1"
nix-repl> nixpkgs.<TAB>
<UX delight ensues as all top-level flake attrs are listed>
Also interesting
# nix repl . .#inputs.nixpkgs
Added 2 variables
nix-repl> foo.<TAB>
nix-repl> nixpkgs.lib.concatStringsSep ":" ["testing" "it"]
There was a problem hiding this comment.
The only problem with this is that flakes don't have an obvious name, so it's not entirely straightforward what the top-level attribute name (e.g. nixpkgs) should be.
There was a problem hiding this comment.
Right. I pulled foo out of thin air.
Most flake refs have a somewhat straightforward candidate for a name.
Using dirname $PWD for . has produced mixed success in the past though.
Maybe the attribute name should be provided by the user.
nix repl --bind foo . --bind nixpkgs .#inputs.nixpkgs
or
nix repl foo=. nixpkgs=.#inputs.nixpkgs
Adding a bare flake or installable to the top-level scope seems ok-ish as long as there's only one. Or maybe it should default to flake= for a flake and a name derived from the installable otherwise?
There was a problem hiding this comment.
We do have the previous behavior of multiple --files to worry about.
I wouldn't mind if it just made an array called args, hah! Then don't have to worry about names, and :a can put whatever one likes at the top level.
|
Suggestions from NixUX:
Fixes: #5824 |
thufschmitt
left a comment
There was a problem hiding this comment.
Left a couple of small stylistic comments, but nothing really serious.
I’m a bit more concerned about the unexpect{ed,able} backwards-compatibility breakage. Maybe that could be eased by
- Gating the change behind an xp feature flag (if possible making the non-experimental behavior just a layer on top of the new one, otherwise by just brutally duplicating everything)
- Adding a flag
--fileto the “legacy” codepath (that would essentially be a no-op but allows a common interface between both versions) - Warn about usages of
nix repl foo.nix, suggest using--file - After one (or two) releases, switch the default to the new behavior and remove the old codepath
Also (somewhat related to the above), --file apparently doesn’t auto-call functions properly anymore, so nix repl --file '<nixpkgs>' fails with error: value is a function while a set was expected
If experimental feature "flakes" is enabled, args passed to `nix repl` will now be considered flake refs and imported using the existing `:load-flake` machinery. In addition, `:load-flake` now supports loading flake fragments.
repl: search installable with findAlongAttrPath repl: refactor handling of args repl: temp
Co-authored-by: Théophane Hufschmitt <[email protected]>
Style fixes from @edolstra Co-authored-by: Eelco Dolstra <[email protected]>
Co-authored-by: Eelco Dolstra <[email protected]>
|
@tomberek I’ve added some tests in thufschmitt@1b00dcb if you want to cherry-pick that |
- Test that without the XP feature things work as before - Test that with or without the XP feature `--file file` works - Test that with XP feature passing a flakeref works - Test `:reload` with a flake
thufschmitt
left a comment
There was a problem hiding this comment.
Thanks for keeping through my annoying reviews. Except for the small test failure, that’s looking good now!
Co-authored-by: Théophane Hufschmitt <[email protected]>
cbabcf7 to
36ce1fb
Compare
|
@bburdette my rebase caused me to interact a bit with your refactor. Please let me know if I've incorrectly resolved something. |
|
@tomberek as far as I can tell its fine. |
thufschmitt
left a comment
There was a problem hiding this comment.
Duh sorry, I though I had it already merged.
I have a couple suggestions for the non-code side, and there's a merge conflict, but looks good otherwise 👍
Co-authored-by: Théophane Hufschmitt <[email protected]>
|
@tomberek think you can have a look at the failing test? |
thufschmitt
left a comment
There was a problem hiding this comment.
Thanks :)
The hardcoded ca-derivations xp feature in the test is a bit annoying, but that'll do for now
Based on: #5824
Add ability to
nix replto utilize installables syntax.TODO: more tests
Fixes #5824