nixos/starship: allow setting package

This commit is contained in:
éclairevoyant 2024-03-19 08:59:01 -04:00 committed by tomf
parent 724c33094e
commit 4f9d91e276

View File

@ -12,7 +12,7 @@ let
nativeBuildInputs = [ pkgs.yq ]; nativeBuildInputs = [ pkgs.yq ];
} '' } ''
tomlq -s -t 'reduce .[] as $item ({}; . * $item)' \ tomlq -s -t 'reduce .[] as $item ({}; . * $item)' \
${lib.concatStringsSep " " (map (f: "${pkgs.starship}/share/starship/presets/${f}.toml") cfg.presets)} \ ${lib.concatStringsSep " " (map (f: "${cfg.package}/share/starship/presets/${f}.toml") cfg.presets)} \
${userSettingsFile} \ ${userSettingsFile} \
> $out > $out
''; '';
@ -28,6 +28,8 @@ in
options.programs.starship = { options.programs.starship = {
enable = lib.mkEnableOption (lib.mdDoc "the Starship shell prompt"); enable = lib.mkEnableOption (lib.mdDoc "the Starship shell prompt");
package = lib.mkPackageOption pkgs "starship" { };
interactiveOnly = lib.mkOption { interactiveOnly = lib.mkOption {
default = true; default = true;
example = false; example = false;
@ -68,7 +70,7 @@ in
if [[ ! -f "$HOME/.config/starship.toml" ]]; then if [[ ! -f "$HOME/.config/starship.toml" ]]; then
export STARSHIP_CONFIG=${settingsFile} export STARSHIP_CONFIG=${settingsFile}
fi fi
eval "$(${pkgs.starship}/bin/starship init bash)" eval "$(${cfg.package}/bin/starship init bash)"
fi fi
''; '';
@ -81,7 +83,7 @@ in
if not test -f "$HOME/.config/starship.toml"; if not test -f "$HOME/.config/starship.toml";
set -x STARSHIP_CONFIG ${settingsFile} set -x STARSHIP_CONFIG ${settingsFile}
end end
eval (${pkgs.starship}/bin/starship init fish) eval (${cfg.package}/bin/starship init fish)
end end
''; '';
@ -94,7 +96,7 @@ in
if [[ ! -f "$HOME/.config/starship.toml" ]]; then if [[ ! -f "$HOME/.config/starship.toml" ]]; then
export STARSHIP_CONFIG=${settingsFile} export STARSHIP_CONFIG=${settingsFile}
fi fi
eval "$(${pkgs.starship}/bin/starship init zsh)" eval "$(${cfg.package}/bin/starship init zsh)"
fi fi
''; '';
}; };