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

nixos/fish: generate autocompletions from man pages #52464

Merged
merged 1 commit into from Feb 25, 2019

Conversation

hyperfekt
Copy link
Contributor

Motivation for this change

The fish shell has the ability to autocomplete commands. For this it uses completions that are either manually defined (coming with fish or the respective software package), or parsed from man pages.
On other systems, users have to run fish_update_completions to regenerate those parsed completions after installing new software. Since on NixOS we are the ones responsible for installed software, we can automate the process.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
  • 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"p
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@hyperfekt
Copy link
Contributor Author

hyperfekt commented Dec 18, 2018

Thank you.
Last problem is that I'm getting this output and I cannot figure out where those two lines in the middle are coming from:

building '/nix/store/ypk9z7pj7cgswyv1j4k7j57x9mriakdh-youtube-dl-2018.11.07-fish-completions.drv'...
building '/nix/store/i6zgwdqnyj1qhycfanxpsqnzck7dlql8-system-fish-completions.drv'...
uptime.fish: /nix/store/17fcq24gs736khpsx70pvn90nqpifyxl-coreutils-8.29-fish-completions/uptime.fish
kill.fish: /nix/store/17fcq24gs736khpsx70pvn90nqpifyxl-coreutils-8.29-fish-completions/kill.fish
building '/nix/store/p4gal0f9vmnbfsnasjqxssvxgky6mhyl-etc.drv'...
building '/nix/store/8fjrgary8pjkhplip3wwk19gqd2jr40p-nixos-system-bismuth-18.09.1676.7e88992a8c7.drv'...

Ideally they'd be suppressed...

EDIT: Solved.

@hyperfekt hyperfekt force-pushed the fish_generate-completions branch 3 times, most recently from f381bd5 to 5eb556e Compare January 1, 2019 22:14
@hyperfekt
Copy link
Contributor Author

hyperfekt commented Jan 1, 2019

If anyone wants to help me find out how to get rid of the superfluous output or improve the performance of the generation (most of the time seems to be spent not in python but in nix-daemon?), I'd be very grateful. Apart from that, I consider this PR done.

@hyperfekt
Copy link
Contributor Author

I changed the interpreter to Python 2 (turns out it has about half the startup time compared to Python 3), and got rid of the superfluous output (turns out it was lndir complaining about already existing symlinks, I now use a modified symlinkJoin that uses cp -srf instead to overwrite them based on meta.priority).

@nixos-discourse
Copy link

This pull request has been mentioned on Nix community. There might be relevant details there:

https://discourse.nixos.org/t/nixos-19-03-feature-freeze/1950/35

@FRidh
Copy link
Member

FRidh commented Feb 24, 2019

I changed the interpreter to Python 2 (turns out it has about half the startup time compared to Python 3)

I don't think that should be the motivation. Python 2 is EOL in 2020, so we should be migrating away from it. If someone doesn't care about it, then they should pick python2 themselves.

@hyperfekt
Copy link
Contributor Author

hyperfekt commented Feb 24, 2019

migrating away

Done.

nixos/modules/programs/fish.nix Outdated Show resolved Hide resolved
nixos/modules/programs/fish.nix Outdated Show resolved Hide resolved
nixos/modules/programs/fish.nix Show resolved Hide resolved
@hyperfekt hyperfekt force-pushed the fish_generate-completions branch 3 times, most recently from 0d2b3c6 to 917de02 Compare February 24, 2019 22:29
@hyperfekt
Copy link
Contributor Author

I gave using string split0 and string join0 another try after having previously failed a few times and managed to get it working. This module should now be able to handle any paths that don't include a newline, however it now requires fish 3 at minimum.

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

9 participants