Merge pull request #200752 from laalsaas/fzf

This commit is contained in:
Sandro 2022-12-03 04:41:35 +01:00 committed by GitHub
commit 9125a8b5c8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 61 additions and 17 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 ];
}

View file

@ -1,5 +1,12 @@
{ lib, buildGoModule, fetchFromGitHub, writeText, runtimeShell, ncurses, perl }:
{ lib
, buildGoModule
, fetchFromGitHub
, writeText
, runtimeShell
, installShellFiles
, ncurses
, perl
}:
buildGoModule rec {
pname = "fzf";
version = "0.35.1";
@ -15,7 +22,7 @@ buildGoModule rec {
outputs = [ "out" "man" ];
fishHook = writeText "load-fzf-keybindings.fish" "fzf_key_bindings";
nativeBuildInputs = [ installShellFiles ];
buildInputs = [ ncurses ];
@ -38,22 +45,19 @@ buildGoModule rec {
--replace " perl -n " " ${perl}/bin/perl -n "
'';
preInstall = ''
mkdir -p $out/share/fish/{vendor_functions.d,vendor_conf.d}
cp shell/key-bindings.fish $out/share/fish/vendor_functions.d/fzf_key_bindings.fish
cp ${fishHook} $out/share/fish/vendor_conf.d/load-fzf-key-bindings.fish
'';
postInstall = ''
cp bin/fzf-tmux $out/bin
install bin/fzf-tmux $out/bin
mkdir -p $man/share/man
cp -r man/man1 $man/share/man
installManPage man/man1/fzf.1 man/man1/fzf-tmux.1
mkdir -p $out/share/vim-plugins/${pname}
cp -r plugin $out/share/vim-plugins/${pname}
install -D plugin/* -t $out/share/vim-plugins/${pname}/plugin
# 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
echo fzf_key_bindings > $out/share/fish/vendor_conf.d/load-fzf-key-bindings.fish
cp -R shell $out/share/fzf
cat <<SCRIPT > $out/bin/fzf-share
#!${runtimeShell}
# Run this script to find the fzf shared folder where all the shell