Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fzf: 0.47.0 -> 0.49.0 #298692

Merged
merged 7 commits into from
Apr 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions doc/packages/shell-helpers.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

Some packages provide the shell integration to be more useful. But unlike other systems, nix doesn't have a standard `share` directory location. This is why a bunch `PACKAGE-share` scripts are shipped that print the location of the corresponding shared folder. Current list of such packages is as following:

- `fzf` : `fzf-share`
- `sk` : `sk-share`

E.g. `fzf` can then be used in the `.bashrc` like this:
E.g. `sk` can then be used in the `.bashrc` like this:

```bash
source "$(fzf-share)/completion.bash"
source "$(fzf-share)/key-bindings.bash"
source "$(sk-share)/completion.bash"
source "$(sk-share)/key-bindings.bash"
```
2 changes: 1 addition & 1 deletion nixos/doc/manual/release-notes/rl-2305.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ In addition to numerous new and updated packages, this release has the following

- [frigate](https://frigate.video), an open source NVR built around real-time AI object detection. Available as [services.frigate](#opt-services.frigate.enable).

- [fzf](https://github.com/junegunn/fzf), a command line fuzzyfinder. Available as [programs.fzf](#opt-programs.fzf.fuzzyCompletion).
- [fzf](https://github.com/junegunn/fzf), a command line fuzzyfinder. Available as [programs.fzf](#opt-programs.fzf.enable).
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if that's ok but the manual seems to build against the current state not the state it was made so I get a build-error of the changelog if the old option is still referenced with #opt here. Alternative would be to remove the link "#opt" and leave it as text.


- [gemstash](https://github.com/rubygems/gemstash), a RubyGems.org cache and private gem server. Available as [services.gemstash](#opt-services.gemstash.enable).

Expand Down
2 changes: 2 additions & 0 deletions nixos/doc/manual/release-notes/rl-2405.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ The pre-existing [services.ankisyncd](#opt-services.ankisyncd.enable) has been m

- `xxd` has been moved from `vim` default output to its own output to reduce closure size. The canonical way to reference it across all platforms is `unixtools.xxd`.

- `programs.fzf.keybindings` and `programs.fzf.fuzzyCompletion` got replaced by `programs.fzf.enabled` as shell-completion is included in the fzf-binary now there is no easy option to load completion and keybindings separately. Please consult fzf-documentation on how to configure/disable certain keybindings.

- The `stalwart-mail` package has been updated to v0.5.3, which includes [breaking changes](https://github.com/stalwartlabs/mail-server/blob/v0.5.3/UPGRADING.md).

- `services.zope2` has been removed as `zope2` is unmaintained and was relying on Python2.
Expand Down
48 changes: 31 additions & 17 deletions nixos/modules/programs/fzf.nix
Original file line number Diff line number Diff line change
@@ -1,32 +1,46 @@
{ pkgs, config, lib, ... }:

with lib;

let
cfg = config.programs.fzf;

in
{
imports = [
(lib.mkRemovedOptionModule [ "programs" "fzf" "keybindings" ] ''
Use "programs.fzf.enabled" 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.
'')
(lib.mkRemovedOptionModule [ "programs" "fzf" "fuzzyCompletion" ] ''
Use "programs.fzf.enabled" 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.
'')
];

options = {
programs.fzf = {
fuzzyCompletion = mkEnableOption (mdDoc "fuzzy completion with fzf");
keybindings = mkEnableOption (mdDoc "fzf keybindings");
};
programs.fzf.enable = mkEnableOption (mdDoc "fuzzy completion with fzf and keybindings");
};
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
config = mkIf cfg.enable {
environment.systemPackages = [ pkgs.fzf ];

programs.bash.interactiveShellInit = ''
eval "$(${getExe pkgs.fzf} --bash)"
'';

programs.fish.interactiveShellInit = ''
${getExe pkgs.fzf} --fish | source
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we do this for the others as well?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's just the fish setup that is different
image

'';

programs.zsh.interactiveShellInit = optionalString (!config.programs.zsh.ohMyZsh.enable)
(optionalString cfg.fuzzyCompletion ''
source ${pkgs.fzf}/share/fzf/completion.zsh
'' + optionalString cfg.keybindings ''
source ${pkgs.fzf}/share/fzf/key-bindings.zsh
'');
programs.zsh = {
interactiveShellInit = optionalString (!config.programs.zsh.ohMyZsh.enable) ''
eval "$(${getExe pkgs.fzf} --zsh)"
'';

programs.zsh.ohMyZsh.plugins = lib.mkIf (cfg.keybindings || cfg.fuzzyCompletion) [ "fzf" ];
ohMyZsh.plugins = mkIf (config.programs.zsh.ohMyZsh.enable) [ "fzf" ];
};
};

meta.maintainers = with maintainers; [ laalsaas ];
}
48 changes: 6 additions & 42 deletions pkgs/tools/misc/fzf/default.nix
Original file line number Diff line number Diff line change
@@ -1,39 +1,25 @@
{ stdenv
, lib
{ lib
, buildGoModule
, fetchFromGitHub
, writeShellScriptBin
, runtimeShell
, installShellFiles
, bc
, ncurses
, perl
, testers
, fzf
}:

let
# on Linux, wrap perl in the bash completion scripts with the glibc locales,
# so that using the shell completion (ctrl+r, etc) doesn't result in ugly
# warnings on non-nixos machines
ourPerl = if !stdenv.isLinux then perl else (
writeShellScriptBin "perl" ''
export PERL_BADLANG=0
exec ${perl}/bin/perl "$@"
'');
in
buildGoModule rec {
pname = "fzf";
version = "0.47.0";
version = "0.49.0";

src = fetchFromGitHub {
owner = "junegunn";
repo = pname;
rev = version;
hash = "sha256-rIRn8g4j/drWEHnvZnJW2sSLq5mrw8Q2pn3LN2sEXDY=";
hash = "sha256-XecMHKi5JMWx3RHQRk2FqS3SjyR6KzWjfyQ5JCI45xM=";
};

vendorHash = "sha256-BOPACUQKcllmA2eWQs+sOfofAQLle2Byb/rZgOhmkVY=";
vendorHash = "sha256-ZEwB2GKohmOx8xosj14VII6sQ4a82s7+h9r620MKEeU=";

CGO_ENABLED = 0;

Expand All @@ -56,14 +42,9 @@ buildGoModule rec {
exit 1
fi

# Has a sneaky dependency on perl
# Include first args to make sure we're patching the right thing
substituteInPlace shell/key-bindings.bash \
--replace "command -v perl" "command -v ${ourPerl}/bin/perl" \
--replace " perl -n " " ${ourPerl}/bin/perl -n "
# fzf-tmux depends on bc
substituteInPlace bin/fzf-tmux \
--replace "bc" "${bc}/bin/bc"
substituteInPlace bin/fzf-tmux \
--replace "bc" "${bc}/bin/bc"
'';

postInstall = ''
Expand All @@ -74,23 +55,6 @@ buildGoModule rec {
install -D plugin/* -t $out/share/vim-plugins/${pname}/plugin
mkdir -p $out/share/nvim
ln -s $out/share/vim-plugins/${pname} $out/share/nvim/site

# 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
cat << EOF > $out/share/fish/vendor_conf.d/load-fzf-key-bindings.fish
status is-interactive; or exit 0
fzf_key_bindings
EOF

cat <<SCRIPT > $out/bin/fzf-share
#!${runtimeShell}
# Run this script to find the fzf shared folder where all the shell
# integration scripts are living.
echo $out/share/fzf
SCRIPT
chmod +x $out/bin/fzf-share
'';

passthru.tests.version = testers.testVersion {
Expand Down
Loading