From 2f8d24b7f57fdd404defe84626b08f3318612f8c Mon Sep 17 00:00:00 2001 From: Adam Stephens Date: Fri, 17 Mar 2023 14:21:53 -0400 Subject: [PATCH] zoxide: enable nushell integration --- modules/programs/zoxide.nix | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/modules/programs/zoxide.nix b/modules/programs/zoxide.nix index 21bc9632e..2640f1008 100644 --- a/modules/programs/zoxide.nix +++ b/modules/programs/zoxide.nix @@ -6,6 +6,8 @@ let cfg = config.programs.zoxide; + cfgOptions = concatStringsSep " " cfg.options; + in { meta.maintainers = [ maintainers.marsam ]; @@ -53,27 +55,42 @@ in { Whether to enable Fish integration. ''; }; + + enableNushellIntegration = mkOption { + default = true; + type = types.bool; + description = '' + Whether to enable Nushell integration. + ''; + }; }; config = mkIf cfg.enable { home.packages = [ cfg.package ]; programs.bash.initExtra = mkIf cfg.enableBashIntegration '' - eval "$(${cfg.package}/bin/zoxide init bash ${ - concatStringsSep " " cfg.options - })" + eval "$(${cfg.package}/bin/zoxide init bash ${cfgOptions})" ''; programs.zsh.initExtra = mkIf cfg.enableZshIntegration '' - eval "$(${cfg.package}/bin/zoxide init zsh ${ - concatStringsSep " " cfg.options - })" + eval "$(${cfg.package}/bin/zoxide init zsh ${cfgOptions})" ''; programs.fish.shellInit = mkIf cfg.enableFishIntegration '' - ${cfg.package}/bin/zoxide init fish ${ - concatStringsSep " " cfg.options - } | source + ${cfg.package}/bin/zoxide init fish ${cfgOptions} | source ''; + + 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 + ''; + }; }; }