From 7ae7250df8f38c4efc8cd6669a36272ab7a575ed Mon Sep 17 00:00:00 2001 From: Philipp Mildenberger Date: Sun, 23 Oct 2022 19:12:01 +0200 Subject: [PATCH] starship: add nushell integration support --- modules/programs/starship.nix | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/modules/programs/starship.nix b/modules/programs/starship.nix index 58ec518a..0a83a7b8 100644 --- a/modules/programs/starship.nix +++ b/modules/programs/starship.nix @@ -89,6 +89,14 @@ in { Whether to enable Ion integration. ''; }; + + enableNushellIntegration = mkOption { + default = true; + type = types.bool; + description = '' + Whether to enable Nushell integration. + ''; + }; }; config = mkIf cfg.enable { @@ -116,10 +124,21 @@ in { end ''; - programs.ion.initExtra = mkIf cfg.enableIonIntegration '' - if test $TERM != "dumb" && not exists -s INSIDE_EMACS || test $INSIDE_EMACS = "vterm" - eval $(${starshipCmd} init ion) - end - ''; + programs.nushell = mkIf cfg.enableNushellIntegration { + # Unfortunately nushell doesn't allow conditionally sourcing nor + # conditionally setting (global) environment variables, which is why the + # check for terminal compatibility (as seen above for the other shells) is + # not done here. + extraEnv = '' + let starship_cache = "${config.xdg.cacheHome}/starship" + if not ($starship_cache | path exists) { + mkdir $starship_cache + } + ${starshipCmd} init nu | save ${config.xdg.cacheHome}/starship/init.nu + ''; + extraConfig = '' + source ${config.xdg.cacheHome}/starship/init.nu + ''; + }; }; }