1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6 cfg = config.programs.starship;
7
8 settingsFormat = pkgs.formats.toml { };
9
10 settingsFile = settingsFormat.generate "starship.toml" cfg.settings;
11
12in {
13 options.programs.starship = {
14 enable = mkEnableOption (lib.mdDoc "the Starship shell prompt");
15
16 settings = mkOption {
17 inherit (settingsFormat) type;
18 default = { };
19 description = lib.mdDoc ''
20 Configuration included in `starship.toml`.
21
22 See https://starship.rs/config/#prompt for documentation.
23 '';
24 };
25 };
26
27 config = mkIf cfg.enable {
28 programs.bash.promptInit = ''
29 if [[ $TERM != "dumb" && (-z $INSIDE_EMACS || $INSIDE_EMACS == "vterm") ]]; then
30 export STARSHIP_CONFIG=${settingsFile}
31 eval "$(${pkgs.starship}/bin/starship init bash)"
32 fi
33 '';
34
35 programs.fish.promptInit = ''
36 if test "$TERM" != "dumb" -a \( -z "$INSIDE_EMACS" -o "$INSIDE_EMACS" = "vterm" \)
37 set -x STARSHIP_CONFIG ${settingsFile}
38 eval (${pkgs.starship}/bin/starship init fish)
39 end
40 '';
41
42 programs.zsh.promptInit = ''
43 if [[ $TERM != "dumb" && (-z $INSIDE_EMACS || $INSIDE_EMACS == "vterm") ]]; then
44 export STARSHIP_CONFIG=${settingsFile}
45 eval "$(${pkgs.starship}/bin/starship init zsh)"
46 fi
47 '';
48 };
49
50 meta.maintainers = pkgs.starship.meta.maintainers;
51}