Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions modules/misc/news/2025/11/2025-11-25_18-16-22.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{ config, ... }:
{
time = "2025-11-25T17:16:22+00:00";
condition = config.programs.starship.enable;
message = ''
The starship module has a new option, programs.starship.presets, which allows for merging user configuration with bundled presets.
'';
}
37 changes: 34 additions & 3 deletions modules/programs/starship.nix
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ in
'';
};

presets = mkOption {
type = with types; listOf str;
default = [ ];
example = [ "nerd-font-symbols" ];
description = ''
Preset files to be merged with settings in order.

See <https://starship.rs/presets/> for the full list of available presets.
'';
};

enableBashIntegration = lib.hm.shell.mkBashIntegrationOption { inherit config; };

enableFishIntegration = lib.hm.shell.mkFishIntegrationOption { inherit config; };
Expand Down Expand Up @@ -99,9 +110,29 @@ in

sessionVariables.STARSHIP_CONFIG = cfg.configPath;

file.${cfg.configPath} = mkIf (cfg.settings != { }) {
source = tomlFormat.generate "starship-config" cfg.settings;
};
file.${cfg.configPath} =
let
settingsFile = tomlFormat.generate "starship-config" cfg.settings;
in
if cfg.presets == [ ] then
{ source = settingsFile; }
else
{
source =
pkgs.runCommand "starship.toml"
{
nativeBuildInputs = [ pkgs.yq ];
}
''
tomlq -s -t 'reduce .[] as $item ({}; . * $item)' \
${
lib.concatStringsSep " " (map (f: "${cfg.package}/share/starship/presets/${f}.toml") cfg.presets)
} \
${settingsFile} \
> $out
'';
};

};

programs.bash.initExtra = mkIf cfg.enableBashIntegration ''
Expand Down