From 257a832e61e9058527ad5a8990786218240f6a84 Mon Sep 17 00:00:00 2001 From: laalsaas Date: Fri, 11 Nov 2022 21:08:36 +0100 Subject: [PATCH] fzf: init module --- .../from_md/release-notes/rl-2305.section.xml | 4 +- .../manual/release-notes/rl-2305.section.md | 2 +- nixos/modules/module-list.nix | 1 + nixos/modules/programs/fzf.nix | 37 +++++++++++++++++++ 4 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 nixos/modules/programs/fzf.nix diff --git a/nixos/doc/manual/from_md/release-notes/rl-2305.section.xml b/nixos/doc/manual/from_md/release-notes/rl-2305.section.xml index b730d591868f..c101b5ef805a 100644 --- a/nixos/doc/manual/from_md/release-notes/rl-2305.section.xml +++ b/nixos/doc/manual/from_md/release-notes/rl-2305.section.xml @@ -25,7 +25,9 @@ - Create the first release note entry in this section! + fzf, + a command line fuzzyfinder. Available as + programs.fzf. diff --git a/nixos/doc/manual/release-notes/rl-2305.section.md b/nixos/doc/manual/release-notes/rl-2305.section.md index d630b993c0f4..8f5ebf53b8fd 100644 --- a/nixos/doc/manual/release-notes/rl-2305.section.md +++ b/nixos/doc/manual/release-notes/rl-2305.section.md @@ -14,7 +14,7 @@ In addition to numerous new and upgraded packages, this release has the followin -- 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} diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 18ce9e8a1516..59d6cf165f18 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -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 diff --git a/nixos/modules/programs/fzf.nix b/nixos/modules/programs/fzf.nix new file mode 100644 index 000000000000..0452bf426227 --- /dev/null +++ b/nixos/modules/programs/fzf.nix @@ -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 ]; +}