Skip to content

Commit

Permalink
fzf: Update derivation to not install old auto-completions, Update mo…
Browse files Browse the repository at this point in the history
…dule to load completion for bash, fish and zsh (or oh-my-zsh plugin) with changed way through fzf-binary, Added change to release note as it is backwards-incompatible.
  • Loading branch information
SebTM committed Mar 24, 2024
1 parent 2d8947d commit 7285947
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 26 deletions.
2 changes: 2 additions & 0 deletions nixos/doc/manual/release-notes/rl-2405.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,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 seperatly. 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.
Expand Down
48 changes: 31 additions & 17 deletions nixos/modules/programs/fzf.nix
Original file line number Diff line number Diff line change
@@ -1,32 +1,46 @@
{ pkgs, config, lib, ... }:

with lib;

let
cfg = config.programs.fzf;

in
{
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.
'')
];

options = {
programs.fzf = {
fuzzyCompletion = mkEnableOption (mdDoc "fuzzy completion with fzf");
keybindings = mkEnableOption (mdDoc "fzf keybindings");
};
programs.fzf.enabled = mkEnableOption (mdDoc "fuzzy completion with fzf and keybindings");
};
config = {
environment.systemPackages = optional (cfg.keybindings || cfg.fuzzyCompletion) pkgs.fzf;

programs.bash.interactiveShellInit = optionalString cfg.fuzzyCompletion ''
source ${pkgs.fzf}/share/fzf/completion.bash
'' + optionalString cfg.keybindings ''
source ${pkgs.fzf}/share/fzf/key-bindings.bash
config = mkIf cfg.enabled {
environment.systemPackages = pkgs.fzf;

programs.bash.interactiveShellInit = ''
eval "$(${getExe pkgs.fzf} --bash)"
'';

programs.fish.interactiveShellInit = ''
eval "$(${getExe pkgs.fzf} --fish)"
'';

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.zsh = {
interactiveShellInit = optionalString (!config.programs.zsh.ohMyZsh.enable) ''
eval "$(${getExe pkgs.fzf} --zsh)"
'';

programs.zsh.ohMyZsh.plugins = lib.mkIf (cfg.keybindings || cfg.fuzzyCompletion) [ "fzf" ];
ohMyZsh.plugins = mkIf (config.programs.zsh.ohMyZsh.enable) [ "fzf" ];
};
};

meta.maintainers = with maintainers; [ laalsaas ];
}
9 changes: 0 additions & 9 deletions pkgs/tools/misc/fzf/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7285947

Please sign in to comment.