diff --git a/modules/programs/starship.nix b/modules/programs/starship.nix index 93982b859..2d2e3506e 100644 --- a/modules/programs/starship.nix +++ b/modules/programs/starship.nix @@ -82,13 +82,26 @@ in https://starship.rs/advanced-config/#transientprompt-and-transientrightprompt-in-cmd ''; }; + + configPath = mkOption { + type = lib.types.str; + default = "${config.xdg.configHome}/starship.toml"; + defaultText = lib.literalExpression "\${config.xdg.configHome}/starship.toml"; + description = '' + Relative path to the user's home directory where the Starship config should be stored. + ''; + }; }; config = mkIf cfg.enable { - home.packages = [ cfg.package ]; + home = { + packages = [ cfg.package ]; - xdg.configFile."starship.toml" = mkIf (cfg.settings != { }) { - source = tomlFormat.generate "starship-config" cfg.settings; + sessionVariables.STARSHIP_CONFIG = cfg.configPath; + + file.${cfg.configPath} = mkIf (cfg.settings != { }) { + source = tomlFormat.generate "starship-config" cfg.settings; + }; }; programs.bash.initExtra = mkIf cfg.enableBashIntegration '' diff --git a/tests/modules/programs/starship/settings.nix b/tests/modules/programs/starship/settings.nix index 29688b099..3c7529946 100644 --- a/tests/modules/programs/starship/settings.nix +++ b/tests/modules/programs/starship/settings.nix @@ -46,6 +46,11 @@ }; nmt.script = '' + sessionVarsFile=home-path/etc/profile.d/hm-session-vars.sh + assertFileExists $sessionVarsFile + assertFileContains $sessionVarsFile \ + 'export STARSHIP_CONFIG="/home/hm-user/.config/starship.toml"' + assertFileContent \ home-files/.config/starship.toml \ ${./settings-expected.toml}