mirror of
https://github.com/nix-community/home-manager.git
synced 2024-12-14 11:57:55 +00:00
starship: add option to use community presets
Presets are community-submitted configurations for starship. See: https://starship.rs/presets/#presets
This commit is contained in:
parent
819f682269
commit
daa7ed85f3
2 changed files with 55 additions and 3 deletions
|
@ -628,4 +628,10 @@
|
||||||
keys =
|
keys =
|
||||||
[{ fingerprint = "BC82 4BB5 1656 D144 285E A0EC D382 C4AF EECE AA90"; }];
|
[{ fingerprint = "BC82 4BB5 1656 D144 285E A0EC D382 C4AF EECE AA90"; }];
|
||||||
};
|
};
|
||||||
|
kpbaks = {
|
||||||
|
name = "Kristoffer Plagborg Bak Sørensen";
|
||||||
|
email = "kristoffer.pbs@gmail.com";
|
||||||
|
github = "kpbaks";
|
||||||
|
githubId = 57013304;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ let
|
||||||
starshipCmd = "${config.home.profileDirectory}/bin/starship";
|
starshipCmd = "${config.home.profileDirectory}/bin/starship";
|
||||||
|
|
||||||
in {
|
in {
|
||||||
meta.maintainers = [ ];
|
meta.maintainers = [ maintainers.kpbaks ];
|
||||||
|
|
||||||
options.programs.starship = {
|
options.programs.starship = {
|
||||||
enable = mkEnableOption "starship";
|
enable = mkEnableOption "starship";
|
||||||
|
@ -23,6 +23,34 @@ in {
|
||||||
description = "The package to use for the starship binary.";
|
description = "The package to use for the starship binary.";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
preset = mkOption {
|
||||||
|
# generated with `starship preset --list`
|
||||||
|
type = types.enum [
|
||||||
|
null
|
||||||
|
"bracketed-segments"
|
||||||
|
"gruvbox-rainbow"
|
||||||
|
"jetpack"
|
||||||
|
"nerd-font-symbols"
|
||||||
|
"no-empty-icons"
|
||||||
|
"no-nerd-font"
|
||||||
|
"no-runtime-versions"
|
||||||
|
"pastel-powerline"
|
||||||
|
"plain-text-symbols"
|
||||||
|
"pure-preset"
|
||||||
|
"tokyo-night"
|
||||||
|
];
|
||||||
|
default = null;
|
||||||
|
example = "jetpack";
|
||||||
|
description = ''
|
||||||
|
The community-submitted configuration preset to use.
|
||||||
|
|
||||||
|
See <https://starship.rs/presets/#presets> for previews
|
||||||
|
of each preset.
|
||||||
|
|
||||||
|
Mutually exclusive with programs.starship.settings
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
settings = mkOption {
|
settings = mkOption {
|
||||||
type = tomlFormat.type;
|
type = tomlFormat.type;
|
||||||
default = { };
|
default = { };
|
||||||
|
@ -48,6 +76,8 @@ in {
|
||||||
|
|
||||||
See <https://starship.rs/config/> for the full list
|
See <https://starship.rs/config/> for the full list
|
||||||
of options.
|
of options.
|
||||||
|
|
||||||
|
Mutually exclusive with programs.starship.preset
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -88,9 +118,25 @@ in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
home.packages = [ cfg.package ];
|
home.packages = [ cfg.package ];
|
||||||
|
|
||||||
xdg.configFile."starship.toml" = mkIf (cfg.settings != { }) {
|
warnings = lib.optional (cfg.preset != null && cfg.settings != { })
|
||||||
source = tomlFormat.generate "starship-config" cfg.settings;
|
"programs.starship.settings has no effect when programs.starship.preset != null";
|
||||||
|
|
||||||
|
xdg.configFile."starship.toml" = if cfg.preset != null then
|
||||||
|
let
|
||||||
|
starshipGithub = pkgs.fetchFromGitHub {
|
||||||
|
owner = "starship";
|
||||||
|
repo = "starship";
|
||||||
|
rev = "61c860e1293d446d515203ac44055f7bef77d14a";
|
||||||
|
hash = "sha256-pl3aW4zCM6CcYOL0dUwE56aTC7BJdvdRyo/GudvX7fQ=";
|
||||||
};
|
};
|
||||||
|
in {
|
||||||
|
text = builtins.readFile
|
||||||
|
"${starshipGithub}/docs/public/presets/toml/${cfg.preset}.toml";
|
||||||
|
}
|
||||||
|
else if cfg.settings != { } then {
|
||||||
|
source = tomlFormat.generate "starship-config" cfg.settings;
|
||||||
|
} else
|
||||||
|
{ };
|
||||||
|
|
||||||
programs.bash.initExtra = mkIf cfg.enableBashIntegration ''
|
programs.bash.initExtra = mkIf cfg.enableBashIntegration ''
|
||||||
if [[ $TERM != "dumb" ]]; then
|
if [[ $TERM != "dumb" ]]; then
|
||||||
|
|
Loading…
Reference in a new issue