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 {
|
|
|
|
meta.maintainers = [ maintainers.marsam ];
|
|
|
|
|
|
|
|
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 = [ ];
|
|
|
|
example = [ "--no-aliases" ];
|
|
|
|
description = ''
|
|
|
|
List of options to pass to zoxide.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
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 ];
|
|
|
|
|
|
|
|
programs.bash.initExtra = mkIf cfg.enableBashIntegration ''
|
2023-03-17 19:21:53 +01:00
|
|
|
eval "$(${cfg.package}/bin/zoxide init bash ${cfgOptions})"
|
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
|
|
|
'';
|
|
|
|
|
|
|
|
programs.fish.shellInit = 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
|
|
|
|
}
|
|
|
|
${cfg.package}/bin/zoxide init nushell ${cfgOptions} | save --force ${config.xdg.cacheHome}/zoxide/init.nu
|
|
|
|
'';
|
|
|
|
extraConfig = ''
|
|
|
|
source ${config.xdg.cacheHome}/zoxide/init.nu
|
|
|
|
'';
|
|
|
|
};
|
2020-05-25 11:20:00 +02:00
|
|
|
};
|
|
|
|
}
|