-
-
Notifications
You must be signed in to change notification settings - Fork 30
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
[WIP] Nix 3.0 (+flakes) support #34
Conversation
…ters This requires some fixes in the help-text parser. From now on, `nix <tab>` and `nix build <tab>` (though it still uses NIX_PATH rather than the flake registry) are usable again.
Found a solution that's backwards compatible:
For normal arguments this works (though we should really preserve any
Now I'm getting a weird rendering issue, where the prompt blanks while waiting for completions. Not sure if that's reproducable or not though. |
Nice! I decided to focus on a POC for Nix 2.4 first before taking care of backwards compatibility, but this is something that really has to be fixed 👍 .
Same here. I'll try to fix this tomorrow. I also have a basic POC for flakes and registries as well, so with the next changes I'll push here, we'll hopefully have something usable to test and review :) |
Have basic support for nix-flake references now. Please note that this may contain bugs and is not ready yet as I'm not aware (yet) of all semantics of the new For dogfooding, I'll use my git branch for my local shell now to catch some regressions. |
Needed to fix e.g. `nix edit`.
Been testing this out for a few hours now, and it looks very good so far. I'm using flakes and experimental CLI, so far without any issues, in my default shell. 👍 |
For instance `nix build` allows `<flake>#<name>` where `name` is an attribute in `self.{packages,legacyPackages}.{arch}`. This means that commands like nix shell nixpkgs#nixStable get properly completed now.
Needed for commands like `nix flake check` where the behavior for `nix flake <tab>` must be the same as for `nix <tab>`. This will become relevant in the future as it's planned to namespace even more-commands[1]. For simplicity I didn't test full recursion, we probably have to fix this to support e.g. `nix foo bar baz` in the future. [1] NixOS/nix#3858
|
Tested as well, looks good, assuming that I should not expect flags to update all the way down right now (eg. |
That's right, unfortunately I didn't find an obvious way to fix it right now, but I'll work on this soon :) |
…tions as well This is a more generic solution which would allow arbitrary nesting of commands (e.g. `nix foo bar baz`). It is primarily needed now to make sure that the sub-subcommands get properly interpreted. This fixes bugs like: * Missing command-specific options for sub-subcommands like `nix flake update --impure`. * Completion of the arguments for sub-subcommands works now. * `nix flake --debug <tab>` provides the proper commands. I tried to document the new behavior with comments to make sure that the code in here doesn't become even harder to read as it is now. Pleaes note that I'm not a seasoned ZSH hacker, so I had to use `sed` and `grep` on a few occasions, improvements are very welcome.
Just pushed a change that treats nested commands in a better way by getting rid of the gross Please note that I'm not a seasoned ZSH hacker so I had to use In order to keep this somehow understandable I added a few comments explaining what's happening now. I'll dogfood the change now, however it took me a while to get this together, so I wouldn't be too surprised if this causes a few new regressions. |
With this patch, a flake reference like nix build .#hello gets completed.
AFAICS the basic functionality is now implemented. Before discussing things like backwards-compat etc. I'd love to get some feedback regarding functionality and implementation :) |
FYI it may be better to use |
Today I noticed this is missing: diff --git i/_nixos-rebuild w/_nixos-rebuild
index 3586f24..d30fa71 100644
--- i/_nixos-rebuild
+++ w/_nixos-rebuild
@@ -20,6 +20,7 @@ _arguments \
'--upgrade[Fetch the latest version of NixOS from the NixOS channel]'\
'--install-bootloader[(Re)install bootloader on the configured device]'\
"--no-build-nix[Don't build Nix package manager]"\
+ '--update-input[Update the given flake input (usually "nixpkgs"):flake input:'
'--fast[Equivalent to --no-build-nix --show-trace]'\
'--rollback[Roll back to the previous configuration]'\
'(--profile-name -p)'{--profile-name,-p}'[Profile to use to track current and previous system configurations]:Profile:_nix_profiles'\ Along with a few other options: --recreate-lock-file|--no-update-lock-file|--no-write-lock-file|--no-registries|--commit-lock-file)
lockFlags+=("$i")
;;
--update-input)
j="$1"; shift 1
lockFlags+=("$i" "$j")
;;
--override-input) I couldn't however find where to grab them from the local variables, although I do notice them in |
Yup, another issue is that I'll leave this as "good enough"-solution for now though until it's clear whether that's a suitable approach or the internal completion output of Nix is better (and Nix probably implements such a completion on its own). |
Closing for now. This isn't compatible with current |
For those who are following this thread:
|
Apparently it's been unused for a while nix-community/nix-zsh-completions#34 (comment)
flakes
-support).Todo:
Note: I recommend to review this commit-by-commit, unfortunately the diff grew a bit too much.
PATH?
, see e.g.nix add-to-store --help
for instance)nix build .#packages
)nix flake
subcommandsnix flake cmd
cli optionsflake#attr
-expressions)nix shell nixpkgs#nixStabe
(currently onlynix shell nixpkgs#packages.x86_64-linux.nixStable
gets comleted).--experimental-features
/--log-format
prompt_nix_shell_setup
fornix develop/shell/run
Refs #32