From d44794cfbf7d8f62937b0f63a5484f57a081be64 Mon Sep 17 00:00:00 2001 From: Fernando Rodrigues Date: Sun, 20 Apr 2025 21:33:09 -0300 Subject: [PATCH 1/2] starship: add sigmasquadron to meta.maintainers The module inherits the package's maintainers as the module maintainers. Signed-off-by: Fernando Rodrigues --- pkgs/by-name/st/starship/package.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/by-name/st/starship/package.nix b/pkgs/by-name/st/starship/package.nix index 22feec90455b..76e7fdc124ec 100644 --- a/pkgs/by-name/st/starship/package.nix +++ b/pkgs/by-name/st/starship/package.nix @@ -76,6 +76,7 @@ rustPlatform.buildRustPackage (finalAttrs: { Br1ght0ne Frostman awwpotato + sigmasquadron ]; mainProgram = "starship"; }; From d19a913454088168e2f9b3543930ee3fc39b32e6 Mon Sep 17 00:00:00 2001 From: Fernando Rodrigues Date: Sun, 20 Apr 2025 21:33:09 -0300 Subject: [PATCH 2/2] nixos/starship: add transientPrompt option set for starship on fish shells On `fish`, Starship supports transient prompts with no external dependencies. This commit adds three options that allows users to edit the function bodies of `starship_transient_prompt_func` and `starship_transient_rprompt_func` and call `enable_transience` after the Starship initialisation code is sourced into the shell. This avoids the need for downstream NixOS configurations to use the `programs.fish.promptInit` option with the `lib.mkAfter` function to correctly enable transience. Signed-off-by: Fernando Rodrigues --- nixos/modules/programs/starship.nix | 52 +++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/nixos/modules/programs/starship.nix b/nixos/modules/programs/starship.nix index 17a2cf9b8666..044054c5452f 100644 --- a/nixos/modules/programs/starship.nix +++ b/nixos/modules/programs/starship.nix @@ -65,6 +65,47 @@ in See https://starship.rs/config/#prompt for documentation. ''; }; + + transientPrompt = + let + mkTransientPromptOption = + side: + lib.mkOption { + type = + with lib.types; + nullOr (str // { description = "Fish shell code concatenated with \"\\n\""; }); + description = + let + function = "`starship_transient_${lib.optionalString (side == "right") "r"}prompt_func` function"; + in + '' + Fish code composing the body of the ${function}. The output of + this code will become the ${side} side of the transient prompt. + + Not setting this option (or setting it to `null`) will prevent + the ${function} from being generated. By default, the ${side} + prompt is ${if (side == "right") then "empty" else "a bold-green '❯' character"}. + ''; + example = "starship module ${if (side == "right") then "time" else "character"}"; + default = null; + }; + in + { + enable = lib.mkEnableOption '' + Starship's [transient prompt](https://starship.rs/advanced-config/#transientprompt-and-transientrightprompt-in-fish) + feature in `fish` shells. After a command has been entered, Starship + replaces the usual prompt with the terminal output of the commands + defined in the `programs.starship.transientPrompt.left` + and `programs.starship.transientPrompt.right` options. + + This option only works with `fish`, as `bash` requires a + [custom configuration](https://starship.rs/advanced-config/#transientprompt-and-transientrightprompt-in-bash) + involving [Ble.sh](https://github.com/akinomyoga/ble.sh), which can be + enabled with `programs.bash.blesh.enable`, but not configured using NixOS + ''; + left = mkTransientPromptOption "left"; + right = mkTransientPromptOption "right"; + }; }; config = lib.mkIf cfg.enable { @@ -90,7 +131,18 @@ in if not test -f "$HOME/.config/starship.toml"; set -x STARSHIP_CONFIG ${settingsFile} end + ${lib.optionalString (!isNull cfg.transientPrompt.left) '' + function starship_transient_prompt_func + ${cfg.transientPrompt.left} + end + ''} + ${lib.optionalString (!isNull cfg.transientPrompt.right) '' + function starship_transient_rprompt_func + ${cfg.transientPrompt.right} + end + ''} eval (${cfg.package}/bin/starship init fish) + ${lib.optionalString cfg.transientPrompt.enable "enable_transience"} end '';