2020-05-25 11:20:00 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.programs.zoxide;
|
|
|
|
|
2023-03-17 19:21:53 +01:00
|
|
|
cfgOptions = concatStringsSep " " cfg.options;
|
|
|
|
|
2020-05-25 11:20:00 +02:00
|
|
|
in {
|
2023-06-22 10:16:28 +02:00
|
|
|
meta.maintainers = [ ];
|
2020-05-25 11:20:00 +02:00
|
|
|
|
|
|
|
options.programs.zoxide = {
|
|
|
|
enable = mkEnableOption "zoxide";
|
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.zoxide;
|
2021-10-09 11:14:08 +02:00
|
|
|
defaultText = literalExpression "pkgs.zoxide";
|
2020-05-25 11:20:00 +02:00
|
|
|
description = ''
|
|
|
|
Zoxide package to install.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
options = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [ ];
|
2024-09-17 23:58:03 +02:00
|
|
|
example = [ "--no-cmd" ];
|
2020-05-25 11:20:00 +02:00
|
|
|
description = ''
|
2024-09-12 01:23:08 +02:00
|
|
|
List of options to pass to zoxide init.
|
2020-05-25 11:20:00 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
enableBashIntegration = mkOption {
|
|
|
|
default = true;
|
|
|
|
type = types.bool;
|
|
|
|
description = ''
|
|
|
|
Whether to enable Bash integration.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
enableZshIntegration = mkOption {
|
|
|
|
default = true;
|
|
|
|
type = types.bool;
|
|
|
|
description = ''
|
|
|
|
Whether to enable Zsh integration.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
enableFishIntegration = mkOption {
|
|
|
|
default = true;
|
|
|
|
type = types.bool;
|
|
|
|
description = ''
|
|
|
|
Whether to enable Fish integration.
|
|
|
|
'';
|
|
|
|
};
|
2023-03-17 19:21:53 +01:00
|
|
|
|
|
|
|
enableNushellIntegration = mkOption {
|
|
|
|
default = true;
|
|
|
|
type = types.bool;
|
|
|
|
description = ''
|
|
|
|
Whether to enable Nushell integration.
|
|
|
|
'';
|
|
|
|
};
|
2020-05-25 11:20:00 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
home.packages = [ cfg.package ];
|
|
|
|
|
2024-10-11 23:19:14 +02:00
|
|
|
programs.bash.initExtra = mkIf cfg.enableBashIntegration (mkOrder 150 ''
|
2023-03-17 19:21:53 +01:00
|
|
|
eval "$(${cfg.package}/bin/zoxide init bash ${cfgOptions})"
|
2024-10-11 23:19:14 +02:00
|
|
|
'');
|
2020-05-25 11:20:00 +02:00
|
|
|
|
|
|
|
programs.zsh.initExtra = mkIf cfg.enableZshIntegration ''
|
2023-03-17 19:21:53 +01:00
|
|
|
eval "$(${cfg.package}/bin/zoxide init zsh ${cfgOptions})"
|
2020-05-25 11:20:00 +02:00
|
|
|
'';
|
|
|
|
|
2023-12-21 17:59:24 +01:00
|
|
|
programs.fish.interactiveShellInit = mkIf cfg.enableFishIntegration ''
|
2023-03-17 19:21:53 +01:00
|
|
|
${cfg.package}/bin/zoxide init fish ${cfgOptions} | source
|
2020-05-25 11:20:00 +02:00
|
|
|
'';
|
2023-03-17 19:21:53 +01:00
|
|
|
|
|
|
|
programs.nushell = mkIf cfg.enableNushellIntegration {
|
|
|
|
extraEnv = ''
|
|
|
|
let zoxide_cache = "${config.xdg.cacheHome}/zoxide"
|
|
|
|
if not ($zoxide_cache | path exists) {
|
|
|
|
mkdir $zoxide_cache
|
|
|
|
}
|
2023-12-28 16:47:07 +01:00
|
|
|
${cfg.package}/bin/zoxide init nushell ${cfgOptions} |
|
|
|
|
save --force ${config.xdg.cacheHome}/zoxide/init.nu
|
2023-03-17 19:21:53 +01:00
|
|
|
'';
|
|
|
|
extraConfig = ''
|
|
|
|
source ${config.xdg.cacheHome}/zoxide/init.nu
|
|
|
|
'';
|
|
|
|
};
|
2020-05-25 11:20:00 +02:00
|
|
|
};
|
|
|
|
}
|