Skip to content

Commit

Permalink
nixos/fzf: bring back keybindings and completion option removed in Ni…
Browse files Browse the repository at this point in the history
…xOS#298692

Also drop with lib
  • Loading branch information
SuperSandro2000 committed Apr 11, 2024
1 parent 72ac6b9 commit 527da1f
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 33 deletions.
2 changes: 1 addition & 1 deletion nixos/doc/manual/release-notes/rl-2305.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,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.enable).
- [fzf](https://github.com/junegunn/fzf), a command line fuzzyfinder. Available as [programs.fzf](#opt-programs.fzf.fuzzyCompletion).

- [gemstash](https://github.com/rubygems/gemstash), a RubyGems.org cache and private gem server. Available as [services.gemstash](#opt-services.gemstash.enable).

Expand Down
2 changes: 0 additions & 2 deletions nixos/doc/manual/release-notes/rl-2405.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,6 @@ 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.
Expand Down
52 changes: 22 additions & 30 deletions nixos/modules/programs/fzf.nix
Original file line number Diff line number Diff line change
@@ -1,46 +1,38 @@
{ 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 separately.
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 separately.
If you want to change/disable certain keybindings please check the fzf-documentation.
'')
];

options = {
programs.fzf.enable = mkEnableOption (mdDoc "fuzzy completion with fzf and keybindings");
programs.fzf = {
fuzzyCompletion = lib.mkEnableOption (lib.mdDoc "fuzzy completion with fzf");
keybindings = lib.mkEnableOption (lib.mdDoc "fzf keybindings");
};
};

config = mkIf cfg.enable {
environment.systemPackages = [ pkgs.fzf ];
config = lib.mkIf (cfg.keybindings || cfg.fuzzyCompletion) {
environment.systemPackages = lib.mkIf (cfg.keybindings || cfg.fuzzyCompletion) [ pkgs.fzf ];

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

programs.fish.interactiveShellInit = ''
${getExe pkgs.fzf} --fish | source
'';

programs.zsh = {
interactiveShellInit = optionalString (!config.programs.zsh.ohMyZsh.enable) ''
eval "$(${getExe pkgs.fzf} --zsh)"
programs = {
bash.interactiveShellInit = lib.optionalString cfg.fuzzyCompletion ''
source ${pkgs.fzf}/share/fzf/completion.bash
'' + lib.optionalString cfg.keybindings ''
source ${pkgs.fzf}/share/fzf/key-bindings.bash
'';

ohMyZsh.plugins = mkIf (config.programs.zsh.ohMyZsh.enable) [ "fzf" ];
zsh = {
interactiveShellInit = lib.optionalString (!config.programs.zsh.ohMyZsh.enable)
(lib.optionalString cfg.fuzzyCompletion ''
source ${pkgs.fzf}/share/fzf/completion.zsh
'' + lib.optionalString cfg.keybindings ''
source ${pkgs.fzf}/share/fzf/key-bindings.zsh
'');

ohMyZsh.plugins = lib.mkIf config.programs.zsh.ohMyZsh.enable [ "fzf" ];
};
};
};

meta.maintainers = with maintainers; [ laalsaas ];
meta.maintainers = with lib.maintainers; [ laalsaas ];
}
9 changes: 9 additions & 0 deletions pkgs/tools/misc/fzf/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ buildGoModule rec {
install -D plugin/* -t $out/share/vim-plugins/${pname}/plugin
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
'';

passthru.tests.version = testers.testVersion {
Expand Down

0 comments on commit 527da1f

Please sign in to comment.