fzf: init module

This commit is contained in:
laalsaas 2022-11-11 21:08:36 +01:00
parent 123cdd4990
commit 257a832e61
4 changed files with 42 additions and 2 deletions

View File

@ -25,7 +25,9 @@
<itemizedlist spacing="compact">
<listitem>
<para>
Create the first release note entry in this section!
<link xlink:href="https://github.com/junegunn/fzf">fzf</link>,
a command line fuzzyfinder. Available as
<link linkend="opt-programs.fzf.fuzzyCompletion">programs.fzf</link>.
</para>
</listitem>
</itemizedlist>

View File

@ -14,7 +14,7 @@ In addition to numerous new and upgraded packages, this release has the followin
<!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->
- Create the first release note entry in this section!
- [fzf](https://github.com/junegunn/fzf), a command line fuzzyfinder. Available as [programs.fzf](#opt-programs.fzf.fuzzyCompletion).
## Backward Incompatibilities {#sec-release-23.05-incompatibilities}

View File

@ -165,6 +165,7 @@
./programs/flexoptix-app.nix
./programs/freetds.nix
./programs/fuse.nix
./programs/fzf.nix
./programs/gamemode.nix
./programs/geary.nix
./programs/git.nix

View File

@ -0,0 +1,37 @@
{pkgs, config, lib, ...}:
with lib;
let
cfg = config.programs.fzf;
in {
options = {
programs.fzf = {
fuzzyCompletion = mkOption {
type = types.bool;
description = lib.mdDoc "Whether to use fzf for fuzzy completion";
default = false;
example = true;
};
keybindings = mkOption {
type = types.bool;
description = lib.mdDoc "Whether to set up fzf keybindings";
default = false;
example = true;
};
};
};
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
'';
programs.zsh.interactiveShellInit = optionalString cfg.fuzzyCompletion ''
source ${pkgs.fzf}/share/fzf/completion.zsh
'' + optionalString cfg.keybindings ''
source ${pkgs.fzf}/share/fzf/key-bindings.zsh
'';
};
meta.maintainers = with maintainers; [ laalsaas ];
}