diff --git a/nixos/modules/programs/fzf.nix b/nixos/modules/programs/fzf.nix index 05e39c43c11b8a3..36c410a809581bc 100644 --- a/nixos/modules/programs/fzf.nix +++ b/nixos/modules/programs/fzf.nix @@ -1,41 +1,49 @@ { pkgs, config, lib, ... }: -with lib; - let + inherit (lib) maintainers; + inherit (lib.meta) getExe; + inherit (lib.modules) mkAfter mkIf mkRemovedOptionModule; + inherit (lib.options) mkEnableOption mkPackageOption; + inherit (lib.strings) optionalString; + 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. + (mkRemovedOptionModule [ "programs" "fzf" "keybindings" ] '' + Use "programs.fzf.enable" instead; due to fzf upstream changes, 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. + (mkRemovedOptionModule [ "programs" "fzf" "fuzzyCompletion" ] '' + Use "programs.fzf.enable" instead; due to fzf upstream changes, 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 = { + enable = mkEnableOption "fuzzy completion with fzf and keybindings"; + + package = mkPackageOption pkgs "fzf" { }; + }; }; config = mkIf cfg.enable { - environment.systemPackages = [ pkgs.fzf ]; + environment.systemPackages = [ cfg.package ]; - programs.bash.interactiveShellInit = '' - eval "$(${getExe pkgs.fzf} --bash)" + programs.bash.promptPluginInit = mkAfter '' + eval "$(${getExe cfg.package} --bash)" ''; programs.fish.interactiveShellInit = '' - ${getExe pkgs.fzf} --fish | source + ${getExe cfg.package} --fish | source ''; programs.zsh = { interactiveShellInit = optionalString (!config.programs.zsh.ohMyZsh.enable) '' - eval "$(${getExe pkgs.fzf} --zsh)" + eval "$(${getExe cfg.package} --zsh)" ''; ohMyZsh.plugins = mkIf (config.programs.zsh.ohMyZsh.enable) [ "fzf" ];