nixpkgs/nixos/modules/programs/fzf.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

40 lines
1.2 KiB
Nix
Raw Normal View History

2023-04-08 22:59:58 +02:00
{ pkgs, config, lib, ... }:
2022-11-11 21:08:36 +01:00
let
cfg = config.programs.fzf;
2023-04-08 22:59:58 +02:00
in
{
2022-11-11 21:08:36 +01:00
options = {
programs.fzf = {
fuzzyCompletion = lib.mkEnableOption "fuzzy completion with fzf";
keybindings = lib.mkEnableOption "fzf keybindings";
};
2022-11-11 21:08:36 +01:00
};
2023-04-08 22:59:58 +02:00
config = lib.mkIf (cfg.keybindings || cfg.fuzzyCompletion) {
environment.systemPackages = lib.mkIf (cfg.keybindings || cfg.fuzzyCompletion) [ pkgs.fzf ];
programs = {
# load after programs.bash.enableCompletion
bash.promptPluginInit = lib.mkAfter (lib.optionalString cfg.fuzzyCompletion ''
source ${pkgs.fzf}/share/fzf/completion.bash
'' + lib.optionalString cfg.keybindings ''
source ${pkgs.fzf}/share/fzf/key-bindings.bash
'');
2023-04-08 22:59:58 +02:00
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" ];
};
};
2022-11-11 21:08:36 +01:00
};
meta.maintainers = with lib.maintainers; [ laalsaas ];
2022-11-11 21:08:36 +01:00
}