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

nixos/fzf: add package option, fix ordering, and other cleanup #303201

Closed
wants to merge 5 commits into from
Closed
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
36 changes: 22 additions & 14 deletions nixos/modules/programs/fzf.nix
Original file line number Diff line number Diff line change
@@ -1,41 +1,49 @@
{ pkgs, config, lib, ... }:

with lib;

let
inherit (lib) maintainers;
inherit (lib.meta) getExe;
inherit (lib.modules) mkAfter mkIf mkRemovedOptionModule;
inherit (lib.options) mkEnableOption mkPackageOption;
inherit (lib.strings) optionalString;

cfg = config.programs.fzf;

in
{
imports = [
(lib.mkRemovedOptionModule [ "programs" "fzf" "keybindings" ] ''
Use "programs.fzf.enable" 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.
(mkRemovedOptionModule [ "programs" "fzf" "keybindings" ] ''
Use "programs.fzf.enable" instead; due to fzf upstream changes, 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.enable" 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.
(mkRemovedOptionModule [ "programs" "fzf" "fuzzyCompletion" ] ''
Use "programs.fzf.enable" instead; due to fzf upstream changes, 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.enable = mkEnableOption (mdDoc "fuzzy completion with fzf and keybindings");
programs.fzf = {
enable = mkEnableOption "fuzzy completion with fzf and keybindings";

package = mkPackageOption pkgs "fzf" { };
};
};

config = mkIf cfg.enable {
environment.systemPackages = [ pkgs.fzf ];
environment.systemPackages = [ cfg.package ];

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

programs.fish.interactiveShellInit = ''
${getExe pkgs.fzf} --fish | source
${getExe cfg.package} --fish | source
'';

programs.zsh = {
interactiveShellInit = optionalString (!config.programs.zsh.ohMyZsh.enable) ''
eval "$(${getExe pkgs.fzf} --zsh)"
eval "$(${getExe cfg.package} --zsh)"
'';

ohMyZsh.plugins = mkIf (config.programs.zsh.ohMyZsh.enable) [ "fzf" ];
Expand Down