mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-11-17 14:19:58 +03:00
nixos/starship: add presets
This commit is contained in:
parent
d6984a0f43
commit
68543ba85f
@ -1,13 +1,21 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.programs.starship;
|
||||
|
||||
settingsFormat = pkgs.formats.toml { };
|
||||
|
||||
settingsFile = settingsFormat.generate "starship.toml" cfg.settings;
|
||||
userSettingsFile = settingsFormat.generate "starship.toml" cfg.settings;
|
||||
|
||||
settingsFile = if cfg.presets == [] then userSettingsFile else pkgs.runCommand "starship.toml"
|
||||
{
|
||||
nativeBuildInputs = [ pkgs.yq ];
|
||||
} ''
|
||||
tomlq -s -t 'reduce .[] as $item ({}; . * $item)' \
|
||||
${lib.concatStringsSep " " (map (f: "${pkgs.starship}/share/starship/presets/${f}.toml") cfg.presets)} \
|
||||
${userSettingsFile} \
|
||||
> $out
|
||||
'';
|
||||
|
||||
initOption =
|
||||
if cfg.interactiveOnly then
|
||||
@ -18,19 +26,28 @@ let
|
||||
in
|
||||
{
|
||||
options.programs.starship = {
|
||||
enable = mkEnableOption (lib.mdDoc "the Starship shell prompt");
|
||||
enable = lib.mkEnableOption (lib.mdDoc "the Starship shell prompt");
|
||||
|
||||
interactiveOnly = mkOption {
|
||||
interactiveOnly = lib.mkOption {
|
||||
default = true;
|
||||
example = false;
|
||||
type = types.bool;
|
||||
type = lib.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.
|
||||
'';
|
||||
};
|
||||
|
||||
settings = mkOption {
|
||||
presets = lib.mkOption {
|
||||
default = [ ];
|
||||
example = [ "nerd-font-symbols" ];
|
||||
type = with lib.types; listOf str;
|
||||
description = lib.mdDoc ''
|
||||
Presets files to be merged with settings in order.
|
||||
'';
|
||||
};
|
||||
|
||||
settings = lib.mkOption {
|
||||
inherit (settingsFormat) type;
|
||||
default = { };
|
||||
description = lib.mdDoc ''
|
||||
@ -41,7 +58,7 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
config = lib.mkIf cfg.enable {
|
||||
programs.bash.${initOption} = ''
|
||||
if [[ $TERM != "dumb" ]]; then
|
||||
# don't set STARSHIP_CONFIG automatically if there's a user-specified
|
||||
|
Loading…
Reference in New Issue
Block a user