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
installShellFiles: Enhance installShellCompletion #83630
Conversation
I'd love to write a test suite for |
#82964 is an example of a PR that could make use of this functionality. That PR has $PSC_PACKAGE --bash-completion-script $PSC_PACKAGE > psc-package.bash
$PSC_PACKAGE --fish-completion-script $PSC_PACKAGE > psc-package.fish
$PSC_PACKAGE --zsh-completion-script $PSC_PACKAGE > _psc-package
installShellCompletion \
psc-package.{bash,fish} \
--zsh _psc-package With this enhancement it could be rewritten as installShellCompletion --cmd psc-package \
--bash --exec "$PSC_PACKAGE --bash-completion-script $PSC_PACKAGE" \
--fish --exec "$PSC_PACKAGE --fish-completion-script $PSC_PACKAGE" \
--zsh --exec "$PSC_PACKAGE --zsh-completion-script $PSC_PACKAGE" |
I haven't tried it but wouldn't something like installShellCompletion --bash --name foobar.bash <($out/bin/foobar --bash-completion) work? |
I forgot that was a feature of bash. However, trying it right now on macOS gets me
So at the very least |
Ah, didn't know that macos would have problems with that. When I wrote the comment I tried using Perhaps mkdir -p "$outDir" \
&& cat "$arg" > "$outPath"
&& chmod 644 "$outPath" ? In any case, I'm not against the |
648d6d1
to
13bab4b
Compare
I've updated this PR to remove the |
13bab4b
to
2c18eab
Compare
I just added a second commit that updates |
I’d love to have this new functionality, but I’m really uncomfortable with the amount of complexity it adds to the bash code (and all that command line parsing logic and interacting command line arguments, halp). I’d feel a lot better if there was a test suite and if possible a list of packages that use this feature and whose output could be checked to contain the completions in the right location. Maybe we can reduce the scope and just add the simplest subset of this PR first, instead of doing it all in one go? (Also, this is the first time I’ve seen you here @lilyball, welcome. Awesome avatar :) ) |
@Profpatsch I'd really love a test suite too, but I couldn't find any precedent for writing test suites on package setup hooks so I'm really not sure how to go about doing it. I did manually verify that
I could remove stdin support, but that doesn't really save much. A more compelling argument for removing it is "why have 2 ways to do the same thing?", but I'm conflicted here because I feel like using stdin is perhaps more obvious to people than using FWIW I wrote this package setup hook in the first place (see #65211). |
2c18eab
to
40e20f7
Compare
I went ahead and stripped out the stdin support. Not a huge difference to the patch, but I did it for the conceptual simplification. |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/prs-ready-for-review-may-2019/3032/139 |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/prs-ready-for-review-may-2019/3032/152 |
@lilyball this is looking good to me, though I am no too familiar with this stuff. There are tests in |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/prs-ready-for-review-may-2019/3032/153 |
|
I just added a suite of tests at |
I didn't add the tests anywhere to be invoked automatically though. |
I wasn't sure if I should put it in the release file or not. Are you recommending that I do? Or should I just put it in |
Given that |
I’d go for `staging`
…On Thu, May 21, 2020 at 1:20 AM Lily Ballard ***@***.***> wrote:
Given that darwin.cctools now depends on this, which means all of stdenv
does, do I need to point this at staging? FWIW darwin.cctools just uses
installManPage which this PR doesn't touch.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#83630 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAYB5ZSCHJNC32Q6HJJLBXLRSRQTHANCNFSM4LVXXWFQ>
.
|
I guess it makes sense? I don’t have a good overview on when these are run, probably before advancing channels.
Ah, I wasn’t aware In that case, let’s go for the |
@lilyball Could you please resolve the conflict? |
@Luflosi Sorry, I haven't had time to work on this in ages. I wanted to put the tests into |
I would have had an interest in using this better sooner than later. Most Go tools behave according to what this PR tries to solve. |
I can't promise it but I will do my best to revisit this today. |
Teach installShellCompletion how to install completions from a named pipe. Also add a convenience flag `--cmd NAME` that synthesizes the name for each completion instead of requiring repeated `--name` flags. Usage looks something like installShellCompletion --cmd foobar \ --bash <($out/bin/foobar --bash-completion) \ --fish <($out/bin/foobar --fish-completion) \ --zsh <($out/bin/foobar --zsh-completion) Fixes NixOS#83284
5e7d73c
to
03c9f6a
Compare
I rebased onto |
It has tests, it adds some features, doesn’t seem to break the existing stuff, LGTM! |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/how-many-people-are-paid-to-work-on-nix-nixpkgs/8307/79 |
Motivation for this change
Some packages don't bundle shell completions as files in their source tree but instead synthesize them by invoking the built tool with specific flags. This enhances the
installShellCompletion
command such that it can install these completions without having to pipe them to a file first. To do this, it now supports a named pipe as a path, such as produced by<(cmd)
. It also now has a convenience flag to synthesize the name for all files based on the shell.Examples:
Fixes #83284
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)I tested one package that uses
installShellCompletion
(ffsend
) and it produced the same output. I also manually tested all of the new functionality, including error cases.