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

wrapFish: add fish shell wrapper package #108491

Merged
merged 4 commits into from Jan 11, 2021

Conversation

pacien
Copy link
Contributor

@pacien pacien commented Jan 5, 2021

Motivation for this change

This adds a wrapper for fish which allows creating shells pre-initialised
with some completions, functions, and configuration scripts from given paths
or from fish plugin packages (pkgs.fishPlugins.*).

This is especially handy when one wants to try a plugin in an ephemeral shell.

GitHub: see #107834 (comment)

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • 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 nixpkgs-review --run "nixpkgs-review wip"
  • 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)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
CC

CC @rnhmjoj

This adds a wrapper for fish which allows creating shells pre-initialised
with some completions, functions, and configuration scripts from given paths
or from fish plugin packages (`pkgs.fishPlugins.*`).

This is especially handy when one wants to try a plugin in an ephemeral shell.

GitHub: see NixOS#107834 (comment)
@rnhmjoj
Copy link
Contributor

rnhmjoj commented Jan 7, 2021

Looks good, thank you. Can you write a small chapter in the Nixpkgs manual that documents how to add and use plugins? Something along the line of weechat or urxvt.

@pacien pacien marked this pull request as draft January 8, 2021 23:48
@pacien pacien marked this pull request as ready for review January 11, 2021 00:29
@pacien pacien requested a review from cole-h January 11, 2021 00:29
@pacien
Copy link
Contributor Author

pacien commented Jan 11, 2021

@rnhmjoj Documentation added.

Copy link
Member

@cole-h cole-h left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we also want to define a fish-unwrapped package and redefine fish = wrapFish fish-unwrapped { }; as we do with e.g. neovim? Right now, I don't think there's much point, but in the future it might be more beneficial (and e.g. we might want to get this in at the same time we introduce the wrapper).

doc/builders/packages/fish.section.md Outdated Show resolved Hide resolved
doc/builders/packages/fish.section.md Show resolved Hide resolved
doc/builders/packages/fish.section.md Outdated Show resolved Hide resolved
doc/builders/packages/fish.section.md Outdated Show resolved Hide resolved
@pacien
Copy link
Contributor Author

pacien commented Jan 11, 2021

@cole-h wrote:

Do we also want to define a fish-unwrapped package and redefine fish = wrapFish fish-unwrapped { }; as we do with e.g. neovim? Right now, I don't think there's much point, but in the future it might be more beneficial (and e.g. we might want to get this in at the same time we introduce the wrapper).

I don't see any use case currently either. I think this would be prone to breakage since we would mess-up with environment initialisation, so I think that a proper, separate pull request would be needed to get that done properly. The standalone wrapper is nevertheless still useful both for maintainers and users who might want to test plugins.

@pacien pacien requested a review from cole-h January 11, 2021 01:43
Copy link
Member

@cole-h cole-h left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Diff LGTM, I don't see anything obviously wrong.

doc/builders/packages/fish.section.md Show resolved Hide resolved
Copy link
Contributor

@rnhmjoj rnhmjoj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thank you for the documentation!

@rnhmjoj rnhmjoj merged commit a306b08 into NixOS:master Jan 11, 2021
${fish}/bin/fish --init-command "
set --prepend fish_complete_path ${escapeShellArgs complPath}
set --prepend fish_function_path ${escapeShellArgs funcPath}
for c in {${concatStringsSep "," safeConfPath}}/*; source $c; end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pacien I've just discovered an issue with this line.
When safeConfPath only contains a single element, due to some peculiarity w/ brace expansion in fish [1], the expansion will produce a single value of just that single element wrapped into braces, which in turn will result in a silent failure since that path will not actually exist in the file system.

e.g. if safeConfPath just contains foo, that line produce something like for c in '{foo}/*'; source $c; end which will silently fail, and the corresponding scripts won't be sourced.

Not sure how to fix this. May add a dummy path in the brace force proper expansion?

[1] http://fishshell.com/docs/current/index.html#expand-brace # see examples in the second code block

cole-h pushed a commit that referenced this pull request Feb 16, 2021
This fixes the expansion of the configuration path in the pathological
case of a singleton, which would otherwise be used verbatim with the
surrounding braces for lookup.

GitHub: see #108491 (review)
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

4 participants