1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-12-09 18:41:06 +01:00

starship: build-time nushell config generation

This commit is contained in:
jaredmontoya 2025-03-21 20:17:17 +01:00 committed by Austin Horstman
parent 81f38986a2
commit 98d718b46d
3 changed files with 11 additions and 16 deletions

View file

@ -6,8 +6,6 @@ let
tomlFormat = pkgs.formats.toml { };
starshipCmd = "${config.home.profileDirectory}/bin/starship";
initFish =
if cfg.enableInteractive then "interactiveShellInit" else "shellInitLast";
in {
@ -100,26 +98,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
'';
@ -128,15 +126,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"
''
}
'';
};
};