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

hyperfekt commented Dec 18, 2018

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.

nixos/modules/programs/fish.nix Outdated Show resolved Hide resolved
nixos/modules/programs/fish.nix Outdated Show resolved Hide resolved
@hyperfekt hyperfekt force-pushed the hyperfekt:fish_generate-completions branch Dec 18, 2018
@hyperfekt

This comment has been minimized.

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.

nixos/modules/programs/fish.nix Outdated Show resolved Hide resolved
@hyperfekt hyperfekt force-pushed the hyperfekt:fish_generate-completions branch 3 times, most recently from f381bd5 to 5eb556e Dec 26, 2018
@hyperfekt

This comment has been minimized.

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 hyperfekt force-pushed the hyperfekt:fish_generate-completions branch 2 times, most recently from 2b89e7c to a56cf05 Jan 8, 2019
@hyperfekt

This comment has been minimized.

Copy link
Contributor Author

hyperfekt commented Jan 12, 2019

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).

@hyperfekt hyperfekt force-pushed the hyperfekt:fish_generate-completions branch from a56cf05 to 0637687 Jan 12, 2019
@nixos-discourse

This comment has been minimized.

Copy link

nixos-discourse commented Feb 24, 2019

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

This comment has been minimized.

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 hyperfekt force-pushed the hyperfekt:fish_generate-completions branch from 0637687 to ea19a42 Feb 24, 2019
@hyperfekt

This comment has been minimized.

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 hyperfekt:fish_generate-completions branch 3 times, most recently from 0d2b3c6 to 917de02 Feb 24, 2019
@hyperfekt hyperfekt force-pushed the hyperfekt:fish_generate-completions branch from 917de02 to 5cc6377 Feb 25, 2019
@hyperfekt

This comment has been minimized.

Copy link
Contributor Author

hyperfekt commented Feb 25, 2019

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.

@lheckemann lheckemann merged commit 31f0972 into NixOS:master Feb 25, 2019
9 checks passed
9 checks passed
grahamcofborg-eval ^.^!
Details
grahamcofborg-eval-check-meta config.nix: checkMeta = true
Details
grahamcofborg-eval-nixos-manual nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./nixos/release.nix -A manual
Details
grahamcofborg-eval-nixos-options nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./nixos/release.nix -A options
Details
grahamcofborg-eval-nixpkgs-manual nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./pkgs/top-level/release.nix -A manual
Details
grahamcofborg-eval-nixpkgs-tarball nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./pkgs/top-level/release.nix -A tarball
Details
grahamcofborg-eval-nixpkgs-unstable-jobset nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./pkgs/top-level/release.nix -A unstable
Details
grahamcofborg-eval-package-list nix-env -qa --json --file .
Details
grahamcofborg-eval-package-list-no-aliases nix-env -qa --json --file . --arg config { allowAliases = false; }
Details
@hyperfekt hyperfekt mentioned this pull request Feb 27, 2019
4 of 10 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

9 participants
You can’t perform that action at this time.