NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.37k stars 13.6k forks source link

automatically generate completion for haskell packages with optparse-applicative #147722

Open teto opened 2 years ago

teto commented 2 years ago

Issue description

I wonder if it would be possible to autogenerate zsh/bash/fish completions for haskell packages when detecting that optparse-applicative is a direct dependency ? One could iterate over $out/bin and try to run these commands: https://github.com/pcapriotti/optparse-applicative#bash-zsh-and-fish-completions

maralorn commented 2 years ago

Do you know, that we already have a wrapper that generates the completions? The only thing we don‘t have is autodetection for using that wrapper. Considering that the wrapper can fail, I don‘t think enabling it for everything which has an optparse-applicative dependency is a wise idea.

teto commented 2 years ago

Do you know, that we already have a wrapper that generates the completions?

do you mean "generateOptparseApplicativeCompletion" ? I didnt, I just searched for it because of your remark.

Maybe we can catch when the wrapper fails and ignore the failure (convert it to a warning) ?

maralorn commented 2 years ago

I guess I would be open to a solution like that.

sternenseemann commented 2 years ago

Probably wiser to add a setup hook to optparse-applicative itself which would be executed by reverse dependencies of it.

teto commented 1 year ago

I believe this is solved actually ?

sternenseemann commented 1 year ago

Not really, it still needs some manual intervention.

NorfairKing commented 11 months ago

I think this might accidentally companion libraries for optparse-applicative that don't provide a binary. Or packages that have optparse-applicative as a now-obsolete dependency.