nixpkgs/nixos/modules/programs/starship.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

69 lines
1.6 KiB
Nix
Raw Normal View History

2021-12-23 23:22:39 +01:00
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.starship;
settingsFormat = pkgs.formats.toml { };
settingsFile = settingsFormat.generate "starship.toml" cfg.settings;
initOption =
if cfg.interactiveOnly then
"promptInit"
else
"shellInit";
in
{
2021-12-23 23:22:39 +01:00
options.programs.starship = {
enable = mkEnableOption (lib.mdDoc "the Starship shell prompt");
interactiveOnly = mkOption {
default = true;
example = false;
type = types.bool;
description = lib.mdDoc ''
Whether to enable starship only when the shell is interactive.
Some plugins require this to be set to false to function correctly.
'';
};
2021-12-23 23:22:39 +01:00
settings = mkOption {
inherit (settingsFormat) type;
default = { };
description = lib.mdDoc ''
Configuration included in `starship.toml`.
2021-12-23 23:22:39 +01:00
See https://starship.rs/config/#prompt for documentation.
'';
};
};
config = mkIf cfg.enable {
programs.bash.${initOption} = ''
if [[ $TERM != "dumb" ]]; then
2021-12-23 23:22:39 +01:00
export STARSHIP_CONFIG=${settingsFile}
eval "$(${pkgs.starship}/bin/starship init bash)"
fi
'';
programs.fish.${initOption} = ''
if test "$TERM" != "dumb"
2021-12-23 23:22:39 +01:00
set -x STARSHIP_CONFIG ${settingsFile}
eval (${pkgs.starship}/bin/starship init fish)
end
'';
programs.zsh.${initOption} = ''
if [[ $TERM != "dumb" ]]; then
2021-12-23 23:22:39 +01:00
export STARSHIP_CONFIG=${settingsFile}
eval "$(${pkgs.starship}/bin/starship init zsh)"
fi
'';
};
meta.maintainers = pkgs.starship.meta.maintainers;
}