From 1fb10f5017cfe9ee0c97e5087310c893cfa98103 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Wed, 10 Apr 2024 22:27:33 +0200 Subject: [PATCH 1/3] nixos/fzf: bring back keybindings and completion option removed in #298692 Also drop with lib --- .../manual/release-notes/rl-2305.section.md | 2 +- .../manual/release-notes/rl-2405.section.md | 2 - nixos/modules/programs/fzf.nix | 62 ++++++++----------- pkgs/tools/misc/fzf/default.nix | 9 +++ 4 files changed, 37 insertions(+), 38 deletions(-) diff --git a/nixos/doc/manual/release-notes/rl-2305.section.md b/nixos/doc/manual/release-notes/rl-2305.section.md index 031442940b9e..ce874a6e0b2d 100644 --- a/nixos/doc/manual/release-notes/rl-2305.section.md +++ b/nixos/doc/manual/release-notes/rl-2305.section.md @@ -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). diff --git a/nixos/doc/manual/release-notes/rl-2405.section.md b/nixos/doc/manual/release-notes/rl-2405.section.md index a5e8ab4addfa..e80f9e7a8634 100644 --- a/nixos/doc/manual/release-notes/rl-2405.section.md +++ b/nixos/doc/manual/release-notes/rl-2405.section.md @@ -322,8 +322,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.enable` 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. diff --git a/nixos/modules/programs/fzf.nix b/nixos/modules/programs/fzf.nix index 05e39c43c11b..acc23d75df7b 100644 --- a/nixos/modules/programs/fzf.nix +++ b/nixos/modules/programs/fzf.nix @@ -1,46 +1,38 @@ { pkgs, config, lib, ... }: -with lib; - let cfg = config.programs.fzf; - in { - imports = [ - (lib.mkRemovedOptionModule [ "programs" "fzf" "keybindings" ] '' - Use "programs.fzf.enable" 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.enable" 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"); - }; - - config = mkIf cfg.enable { - environment.systemPackages = [ 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)" - ''; - - ohMyZsh.plugins = mkIf (config.programs.zsh.ohMyZsh.enable) [ "fzf" ]; + programs.fzf = { + fuzzyCompletion = lib.mkEnableOption (lib.mdDoc "fuzzy completion with fzf"); + keybindings = lib.mkEnableOption (lib.mdDoc "fzf keybindings"); }; }; - meta.maintainers = with maintainers; [ laalsaas ]; + config = lib.mkIf (cfg.keybindings || cfg.fuzzyCompletion) { + environment.systemPackages = lib.mkIf (cfg.keybindings || cfg.fuzzyCompletion) [ pkgs.fzf ]; + + 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 + ''; + + 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 lib.maintainers; [ laalsaas ]; } diff --git a/pkgs/tools/misc/fzf/default.nix b/pkgs/tools/misc/fzf/default.nix index 94ec13ead9e4..9f6d94a83920 100644 --- a/pkgs/tools/misc/fzf/default.nix +++ b/pkgs/tools/misc/fzf/default.nix @@ -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 { From 104f24e0b99b6d340c313e8f7c963cb8e9f8ae3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Thu, 11 Apr 2024 13:52:07 +0200 Subject: [PATCH 2/3] Revert "doc: replace fzf-share mention with sk-share from Skim package" This reverts commit de5b2ef096cc03796398f7ca627ad5f4306aa065. --- doc/packages/shell-helpers.section.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/packages/shell-helpers.section.md b/doc/packages/shell-helpers.section.md index 1c73303f8284..e7c2b0abebfc 100644 --- a/doc/packages/shell-helpers.section.md +++ b/doc/packages/shell-helpers.section.md @@ -2,11 +2,11 @@ Some packages provide the shell integration to be more useful. But unlike other systems, nix doesn't have a standard `share` directory location. This is why a bunch `PACKAGE-share` scripts are shipped that print the location of the corresponding shared folder. Current list of such packages is as following: -- `sk` : `sk-share` +- `fzf` : `fzf-share` -E.g. `sk` can then be used in the `.bashrc` like this: +E.g. `fzf` can then be used in the `.bashrc` like this: ```bash -source "$(sk-share)/completion.bash" -source "$(sk-share)/key-bindings.bash" +source "$(fzf-share)/completion.bash" +source "$(fzf-share)/key-bindings.bash" ``` From 15ed0d212574c950e94e56f7ad7ec3c33ee8f772 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Thu, 11 Apr 2024 13:52:44 +0200 Subject: [PATCH 3/3] Revert "fzf: remove fzf-share helper" This reverts commit 1035a9efdfe4456f224a92ed133cf0605b9eb821. --- pkgs/tools/misc/fzf/default.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkgs/tools/misc/fzf/default.nix b/pkgs/tools/misc/fzf/default.nix index 9f6d94a83920..e2ae52985a50 100644 --- a/pkgs/tools/misc/fzf/default.nix +++ b/pkgs/tools/misc/fzf/default.nix @@ -1,6 +1,7 @@ { lib , buildGoModule , fetchFromGitHub +, runtimeShell , installShellFiles , bc , ncurses @@ -64,6 +65,14 @@ buildGoModule rec { status is-interactive; or exit 0 fzf_key_bindings EOF + + cat <