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

nix-bash-completions: 0.5 -> 0.6, nix-zsh-completions: 0.3.5 -> 0.3.6 #32149

Merged
merged 2 commits into from Dec 3, 2017

Conversation

hedning
Copy link
Contributor

@hedning hedning commented Nov 28, 2017

Should be safe to backport to 17.09 as there's nothing which depends on these packages. I've tested installation via nix-env and haven't seen any regressions.

Motivation for this change

The changelog:

bash: v0.6, zsh: 0.3.6

The quest for an awesome completion system continues.

The main bulk of changes apply to both ZSH and Bash, with explicit notes otherwise.

-I/--include support

Attribute path completion now takes -I and --include into account. This makes completion work correctly when doing things like this:

nix-shell -I nixpkgs=. --packages <tab>

When the completion system executes any nix code it will first resolve all URLS in the NIX_PATH, and in -I input, to a local store path if present. This protects against triggering an intrusive download while completing. channel: syntax is correctly translated to its https:// form and resolved to a cache too.

--arg and --argstr support

Argument names are now offered as completions using builtins.functionArgs. Names already supplied on the command line is excluded from completions.

Attribute path completion will also take --arg and --argstr into account, which means things like this work:

nix-instantiate --eval default.nix --argstr bar foo -A <tab>

If the content of default.nix is {bar}: {foo = bar;} then completing will result in foo.

--expr and -E support

Attribute path completion now works for --expr input, including argument name completion.

Note, URLs in the expression body is not yet resolved to a local cache so might trigger a download. This should ideally be fixed.

In ZSH --expr now behaves properly, allowing completion of options after it has been entered (bash already did the correct thing here).

Other small fixes and improvements

  • Most arguments which expects a .nix file will now only offer up those and directories, reducing clutter
  • --file will now complete more than once, the last one being used to generate attribute matches. In ZSH this allows aliasing nix-env to nix-env -f '<nixpkgs>' while still getting further --file completion which can be used to override the default.
  • nix-env now offer --file completion together with main operation completion by default. This is a compromise between discover-ability of main operations and the want to specify common options quickly.
  • --add-root will now off up /nix/var/nix/gcroots/ by default, if --indirect is specified it will give normal directory completion.
  • Add missing --help and --version completion to many commands
  • nix-env: --filter-system will complete possible systems.
  • nix-instantiate: --find-file will no longer offer misleading file completion

And a bunch of other small changes and fixes.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@domenkozar domenkozar merged commit 60d3a11 into NixOS:master Dec 3, 2017
@bjornfor
Copy link
Contributor

bjornfor commented Dec 3, 2017

Also backported to release-17.09 (de7eae5 and parent). Thanks!

@hedning hedning deleted the nix-completions branch March 1, 2020 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants