diff --git a/modules/programs/starship.nix b/modules/programs/starship.nix index c3b2a61ae..459f5e0d5 100644 --- a/modules/programs/starship.nix +++ b/modules/programs/starship.nix @@ -8,8 +8,6 @@ let tomlFormat = pkgs.formats.toml { }; - starshipCmd = "${config.home.profileDirectory}/bin/starship"; - initFish = if cfg.enableInteractive then "interactiveShellInit" else "shellInitLast"; in { @@ -102,26 +100,26 @@ in { programs.bash.initExtra = mkIf cfg.enableBashIntegration '' if [[ $TERM != "dumb" ]]; then - eval "$(${starshipCmd} init bash --print-full-init)" + eval "$(${lib.getExe cfg.package} init bash --print-full-init)" fi ''; programs.zsh.initContent = mkIf cfg.enableZshIntegration '' if [[ $TERM != "dumb" ]]; then - eval "$(${starshipCmd} init zsh)" + eval "$(${lib.getExe cfg.package} init zsh)" fi ''; programs.fish.${initFish} = mkIf cfg.enableFishIntegration '' if test "$TERM" != "dumb" - ${starshipCmd} init fish | source + ${lib.getExe cfg.package} init fish | source ${lib.optionalString cfg.enableTransience "enable_transience"} end ''; programs.ion.initExtra = mkIf cfg.enableIonIntegration '' if test $TERM != "dumb" - eval $(${starshipCmd} init ion) + eval $(${lib.getExe cfg.package} init ion) end ''; @@ -130,15 +128,12 @@ in { # 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 --force ${config.xdg.cacheHome}/starship/init.nu - ''; extraConfig = '' - use ${config.xdg.cacheHome}/starship/init.nu + use ${ + pkgs.runCommand "starship-nushell-config" { } '' + ${lib.getExe cfg.package} init nu >> "$out" + '' + } ''; }; }; diff --git a/tests/modules/programs/starship/fish_with_interactive.nix b/tests/modules/programs/starship/fish_with_interactive.nix index 1fdc3d01c..fdb478179 100644 --- a/tests/modules/programs/starship/fish_with_interactive.nix +++ b/tests/modules/programs/starship/fish_with_interactive.nix @@ -10,7 +10,7 @@ export GOT="$(tail -n 5 `_abs home-files/.config/fish/config.fish`)" export NOT_EXPECTED=" if test \"\$TERM\" != dumb - /home/hm-user/.nix-profile/bin/starship init fish | source + @starship@/bin/starship init fish | source end" diff --git a/tests/modules/programs/starship/fish_without_interactive.nix b/tests/modules/programs/starship/fish_without_interactive.nix index 52150715e..76e06b0d0 100644 --- a/tests/modules/programs/starship/fish_without_interactive.nix +++ b/tests/modules/programs/starship/fish_without_interactive.nix @@ -14,7 +14,7 @@ export GOT="$(tail -n 5 `_abs home-files/.config/fish/config.fish`)" export EXPECTED=" if test \"\$TERM\" != dumb - /home/hm-user/.nix-profile/bin/starship init fish | source + @starship@/bin/starship init fish | source end"