-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Bash completion in nix-shell -p (also solving support for strictDeps by default) #4254
Comments
See also #2504 |
I marked this as stale due to inactivity. → More info |
stable bot: Still broken. A solution is available #4452. If a maintainer agrees with the design, I'll happily rebase it. Otherwise, I can implement any suggestions. |
I marked this as stale due to inactivity. → More info |
A solution is available #4452. If a maintainer agrees with the design, I'll happily rebase it. Otherwise, I can implement any suggestions. |
I marked this as stale due to inactivity. → More info |
Not stale. (I generally don't "unstale" issues, but I think I saw another Nix issue being closed by the Stale bot today, and I don't want that to happen.) |
Sorry, complete nix noob here. With a shellHook in my shell.nix running
when trying to complete kubectl commands beginning with c I get;
Although if I install bash-completion and then manually source /nix/store/....-bash-completion-2.11/etc/profile.d/bash_completion.sh inside the nix-shell I get an additional 72 functions declared, including _get_comp_words_by_ref, and bash completion for kubectl I made the shell load and all the other builtin-it/included completions (wget, etc) function perfectly.
|
Currently, our $XDG_DATA_DIRs and $FPATH solution does not help with the default behaviour of nix-shell [-p], which spawns a full shell, obliviating some need for $FPATH modification post shell start, but which does not export the `share/` of packages, (pending resolution of NixOS/nix#4254) and therefore will not be able to provide completions at all. This commit adds an optional workaround feature which attempts to detect nix `share/` paths based on the bin directories on `$PATH`. It is disabled by default, since this is abusing $PATH for something it is not meant for. However, in practice, it is incredibly unlikely that this will detect any directories that shouldn't be there anyway.
Is your feature request related to a problem? Please describe.
nix-shell
doesn't currently provide bash completion for new commands that provide their own completion scripts.NixOS/nixpkgs#103501 aims to change that, but can't support completions in
nix-shell -p
because that command adds to the wrong attribute,buildInputs
instead ofnativeBuildInputs
.Describe the solution you'd like
nix-shell
should setnativeBuildInputs
(one way or another).This aligns with having
strictDeps
by default (which is not a requirement though). StrictDeps enforces desirable properties like outputs not retaining references to build tools. It also prevents mistakes that break cross-compilation.We can pick from these designs or think of something better.
principled scheme
-p
sets both and emits a warning--tool
adds tonativeBuildInputs
--input
adds tobuildInputs
minimal scheme
-p
setsnativeBuildInputs
--input
adds tobuildInputs
With the minimal scheme we don't have to update all documentation to change
-p
s to--tool
s, but it will silently break somenix-shell
invocations.compatible scheme
Like the principled scheme but without the warning. Does nothing to help towards strictDeps.
Describe alternatives you've considered
Also add
buildInputs
toXDG_DATA_DIRS
, but this "non-strictDeps" behavior is risky, potentially affecting any build in Nixpkgs.Additional context
The text was updated successfully, but these errors were encountered: