starship: give settings
option more specific type
This more readily allows merging configurations. Fixes #1023
This commit is contained in:
parent
2f726bbd1c
commit
acf106ced0
|
@ -31,8 +31,23 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
settings = mkOption {
|
settings = mkOption {
|
||||||
type = types.attrs;
|
type = with types;
|
||||||
|
let
|
||||||
|
prim = either bool (either int str);
|
||||||
|
primOrPrimAttrs = either prim (attrsOf prim);
|
||||||
|
entry = either prim (listOf primOrPrimAttrs);
|
||||||
|
entryOrAttrsOf = t: either entry (attrsOf t);
|
||||||
|
entries = entryOrAttrsOf (entryOrAttrsOf entry);
|
||||||
|
in attrsOf entries // { description = "Starship configuration"; };
|
||||||
default = { };
|
default = { };
|
||||||
|
example = literalExample ''
|
||||||
|
{
|
||||||
|
add_newline = false;
|
||||||
|
prompt_order = [ "line_break" "package" "line_break" "character" ];
|
||||||
|
scan_timeout = 10;
|
||||||
|
character.symbol = "➜";
|
||||||
|
}
|
||||||
|
'';
|
||||||
description = ''
|
description = ''
|
||||||
Configuration written to
|
Configuration written to
|
||||||
<filename>~/.config/starship.toml</filename>.
|
<filename>~/.config/starship.toml</filename>.
|
||||||
|
|
|
@ -37,6 +37,7 @@ import nmt {
|
||||||
./modules/programs/newsboat
|
./modules/programs/newsboat
|
||||||
./modules/programs/readline
|
./modules/programs/readline
|
||||||
./modules/programs/ssh
|
./modules/programs/ssh
|
||||||
|
./modules/programs/starship
|
||||||
./modules/programs/texlive
|
./modules/programs/texlive
|
||||||
./modules/programs/tmux
|
./modules/programs/tmux
|
||||||
./modules/programs/zsh
|
./modules/programs/zsh
|
||||||
|
|
1
tests/modules/programs/starship/default.nix
Normal file
1
tests/modules/programs/starship/default.nix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{ starship-settings = ./settings.nix; }
|
27
tests/modules/programs/starship/settings-expected.toml
Normal file
27
tests/modules/programs/starship/settings-expected.toml
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
add_newline = false
|
||||||
|
prompt_order = ["line_break", "package", "line_break", "character"]
|
||||||
|
scan_timeout = 10
|
||||||
|
|
||||||
|
[aws]
|
||||||
|
disabled = true
|
||||||
|
style = "bold blue"
|
||||||
|
|
||||||
|
[battery]
|
||||||
|
charging_symbol = "⚡️"
|
||||||
|
|
||||||
|
[[battery.display]]
|
||||||
|
style = "bold red"
|
||||||
|
threshold = 10
|
||||||
|
|
||||||
|
[[battery.display]]
|
||||||
|
style = "bold yellow"
|
||||||
|
threshold = 30
|
||||||
|
|
||||||
|
[character]
|
||||||
|
symbol = "➜"
|
||||||
|
|
||||||
|
[memory_usage]
|
||||||
|
threshold = -1
|
||||||
|
|
||||||
|
[package]
|
||||||
|
disabled = true
|
49
tests/modules/programs/starship/settings.nix
Normal file
49
tests/modules/programs/starship/settings.nix
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
{
|
||||||
|
config = {
|
||||||
|
programs.starship = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
settings = mkMerge [
|
||||||
|
{
|
||||||
|
add_newline = false;
|
||||||
|
prompt_order = [ "line_break" "package" "line_break" "character" ];
|
||||||
|
scan_timeout = 10;
|
||||||
|
character.symbol = "➜";
|
||||||
|
package.disabled = true;
|
||||||
|
memory_usage.threshold = -1;
|
||||||
|
aws.style = "bold blue";
|
||||||
|
battery = {
|
||||||
|
charging_symbol = "⚡️";
|
||||||
|
display = [{
|
||||||
|
threshold = 10;
|
||||||
|
style = "bold red";
|
||||||
|
}];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
aws.disabled = true;
|
||||||
|
|
||||||
|
battery.display = [{
|
||||||
|
threshold = 30;
|
||||||
|
style = "bold yellow";
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
nixpkgs.overlays = [
|
||||||
|
(self: super: { starship = pkgs.writeScriptBin "dummy-starship" ""; })
|
||||||
|
];
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
assertFileContent \
|
||||||
|
home-files/.config/starship.toml \
|
||||||
|
${./settings-expected.toml}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue