Skip to content

Commit

Permalink
modules/terminal: restrict colornames
Browse files Browse the repository at this point in the history
  • Loading branch information
t184256 committed Feb 14, 2024
1 parent 41d2f67 commit afcb9c2
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions modules/terminal.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
}:
with lib; let
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
{
###### interface
Expand Down Expand Up @@ -34,6 +38,8 @@ in
'';
description = ''
Colorscheme used for the terminal.
Acceptable attribute names are:
`background`, `foreground`, `cursor` and `color0`-`color15`.
'';
};
};
Expand All @@ -42,6 +48,14 @@ in
###### implementation

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 =
let
fontPath =
Expand Down

0 comments on commit afcb9c2

Please sign in to comment.