mirror of
https://github.com/nix-community/home-manager.git
synced 2026-01-12 01:59:37 +08:00
starship: set STARSHIP_CONFIG var and add option to set config path (#7435)
This commit is contained in:
@@ -82,14 +82,27 @@ 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 != { }) {
|
||||
sessionVariables.STARSHIP_CONFIG = cfg.configPath;
|
||||
|
||||
file.${cfg.configPath} = mkIf (cfg.settings != { }) {
|
||||
source = tomlFormat.generate "starship-config" cfg.settings;
|
||||
};
|
||||
};
|
||||
|
||||
programs.bash.initExtra = mkIf cfg.enableBashIntegration ''
|
||||
if [[ $TERM != "dumb" ]]; then
|
||||
|
||||
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user