modules/terminal: restrict colornames

This commit is contained in:
Alexander Sosedkin 2024-02-14 22:35:21 +01:00
parent f05bfc132d
commit ec5d7f4ccc

View file

@ -6,6 +6,10 @@
}: }:
with lib; let with lib; let
cfg = config.terminal; cfg = config.terminal;
validColornames =
[ "background" "foreground" "cursor" ] ++
(builtins.map (n: "color${builtins.toString n}") (lib.lists.range 0 15));
validColorname = colorName: builtins.elem colorName validColornames;
in in
{ {
###### interface ###### interface
@ -34,6 +38,8 @@ in
''; '';
description = '' description = ''
Colorscheme used for the terminal. Colorscheme used for the terminal.
Acceptable attribute names are:
`background`, `foreground`, `cursor` and `color0`-`color15`.
''; '';
}; };
}; };
@ -42,6 +48,14 @@ in
###### implementation ###### implementation
config = { config = {
assertions = [{
assertion = builtins.all validColorname (attrNames cfg.colors);
message = ''
`terminal.colors` only accepts the following attributes:
`background`, `foreground`, `cursor` and `color0`-`color15`.
'';
}];
build.activation = build.activation =
let let
fontPath = fontPath =