fzf: Update package and module (shell-completions)

Update derivation to not install old shell-completions
Update module to load completion for bash, fish (new) and zsh (or oh-my-zsh plugin) with changed way through fzf-binary
Added change to release note as it is backwards-incompatible.
This commit is contained in:
Sebastian Sellmeier 2024-03-24 18:28:11 +01:00
parent debcd5675a
commit e3812e1875
No known key found for this signature in database
GPG Key ID: 51E2BE0CCC826F98
4 changed files with 36 additions and 29 deletions

View File

@ -77,7 +77,7 @@ In addition to numerous new and updated packages, this release has the following
- [frigate](https://frigate.video), an open source NVR built around real-time AI object detection. Available as [services.frigate](#opt-services.frigate.enable).
- [fzf](https://github.com/junegunn/fzf), a command line fuzzyfinder. Available as [programs.fzf](#opt-programs.fzf.fuzzyCompletion).
- [fzf](https://github.com/junegunn/fzf), a command line fuzzyfinder. Available as [programs.fzf](#opt-programs.fzf.enable).
- [gemstash](https://github.com/rubygems/gemstash), a RubyGems.org cache and private gem server. Available as [services.gemstash](#opt-services.gemstash.enable).

View File

@ -248,6 +248,8 @@ The pre-existing [services.ankisyncd](#opt-services.ankisyncd.enable) has been m
- `xxd` has been moved from `vim` default output to its own output to reduce closure size. The canonical way to reference it across all platforms is `unixtools.xxd`.
- `programs.fzf.keybindings` and `programs.fzf.fuzzyCompletion` got replaced by `programs.fzf.enabled` as shell-completion is included in the fzf-binary now there is no easy option to load completion and keybindings separately. Please consult fzf-documentation on how to configure/disable certain keybindings.
- The `stalwart-mail` package has been updated to v0.5.3, which includes [breaking changes](https://github.com/stalwartlabs/mail-server/blob/v0.5.3/UPGRADING.md).
- `services.zope2` has been removed as `zope2` is unmaintained and was relying on Python2.

View File

@ -1,32 +1,46 @@
{ pkgs, config, lib, ... }:
with lib;
let
cfg = config.programs.fzf;
in
{
options = {
programs.fzf = {
fuzzyCompletion = mkEnableOption (mdDoc "fuzzy completion with fzf");
keybindings = mkEnableOption (mdDoc "fzf keybindings");
};
};
config = {
environment.systemPackages = optional (cfg.keybindings || cfg.fuzzyCompletion) pkgs.fzf;
imports = [
(lib.mkRemovedOptionModule [ "programs" "fzf" "keybindings" ] ''
Use "programs.fzf.enabled" instead, due to fzf upstream-change it's not possible to load shell-completion and keybindings seperatly.
If you want to change/disable certain keybindings please check the fzf-documentation.
'')
(lib.mkRemovedOptionModule [ "programs" "fzf" "fuzzyCompletion" ] ''
Use "programs.fzf.enabled" instead, due to fzf upstream-change it's not possible to load shell-completion and keybindings seperatly.
If you want to change/disable certain keybindings please check the fzf-documentation.
'')
];
programs.bash.interactiveShellInit = optionalString cfg.fuzzyCompletion ''
source ${pkgs.fzf}/share/fzf/completion.bash
'' + optionalString cfg.keybindings ''
source ${pkgs.fzf}/share/fzf/key-bindings.bash
options = {
programs.fzf.enable = mkEnableOption (mdDoc "fuzzy completion with fzf and keybindings");
};
config = mkIf cfg.enable {
environment.systemPackages = [ pkgs.fzf ];
programs.bash.interactiveShellInit = ''
eval "$(${getExe pkgs.fzf} --bash)"
'';
programs.zsh.interactiveShellInit = optionalString (!config.programs.zsh.ohMyZsh.enable)
(optionalString cfg.fuzzyCompletion ''
source ${pkgs.fzf}/share/fzf/completion.zsh
'' + optionalString cfg.keybindings ''
source ${pkgs.fzf}/share/fzf/key-bindings.zsh
'');
programs.fish.interactiveShellInit = ''
eval "$(${getExe pkgs.fzf} --fish)"
'';
programs.zsh.ohMyZsh.plugins = lib.mkIf (cfg.keybindings || cfg.fuzzyCompletion) [ "fzf" ];
programs.zsh = {
interactiveShellInit = optionalString (!config.programs.zsh.ohMyZsh.enable) ''
eval "$(${getExe pkgs.fzf} --zsh)"
'';
ohMyZsh.plugins = mkIf (config.programs.zsh.ohMyZsh.enable) [ "fzf" ];
};
};
meta.maintainers = with maintainers; [ laalsaas ];
}

View File

@ -75,15 +75,6 @@ buildGoModule rec {
mkdir -p $out/share/nvim
ln -s $out/share/vim-plugins/${pname} $out/share/nvim/site
# Install shell integrations
install -D shell/* -t $out/share/fzf/
install -D shell/key-bindings.fish $out/share/fish/vendor_functions.d/fzf_key_bindings.fish
mkdir -p $out/share/fish/vendor_conf.d
cat << EOF > $out/share/fish/vendor_conf.d/load-fzf-key-bindings.fish
status is-interactive; or exit 0
fzf_key_bindings
EOF
cat <<SCRIPT > $out/bin/fzf-share
#!${runtimeShell}
# Run this script to find the fzf shared folder where all the shell