2024-02-18 00:25:18 +00:00
|
|
|
{
|
|
|
|
pkgs,
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}: let
|
2024-02-18 00:51:06 +00:00
|
|
|
# generate shell command options for kmscon fom an attrset
|
2024-02-18 00:25:18 +00:00
|
|
|
generateOptions = with builtins; (
|
|
|
|
opts:
|
|
|
|
toString (
|
|
|
|
attrValues (
|
|
|
|
mapAttrs (name: value: "--${name} ${toString value}") opts
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
2024-02-18 00:51:06 +00:00
|
|
|
# generate a hexadecimal number lookup table to get integers from them
|
2024-02-18 00:25:18 +00:00
|
|
|
hexLookupTable = with lib; (listToAttrs (genList (i: {
|
|
|
|
name = let
|
|
|
|
r = toHexString i;
|
|
|
|
in (
|
2024-02-18 00:51:06 +00:00
|
|
|
# pad with 0 in front if only 1 digit
|
2024-02-18 00:25:18 +00:00
|
|
|
if (stringLength r) == 1
|
|
|
|
then "0${r}"
|
|
|
|
else r
|
|
|
|
);
|
|
|
|
value = toString i;
|
|
|
|
})
|
|
|
|
256));
|
2024-02-18 00:51:06 +00:00
|
|
|
# "parse" hex color strings and convert them to kmscon options
|
2024-02-18 00:25:18 +00:00
|
|
|
hexToOpt = with lib; (color:
|
|
|
|
concatStringsSep "," [
|
|
|
|
(getAttr (substring 1 2 (toUpper color)) hexLookupTable)
|
|
|
|
(getAttr (substring 3 2 (toUpper color)) hexLookupTable)
|
|
|
|
(getAttr (substring 5 2 (toUpper color)) hexLookupTable)
|
|
|
|
]);
|
|
|
|
in {
|
|
|
|
services.kmscon = {
|
|
|
|
enable = true;
|
|
|
|
fonts = [
|
|
|
|
{
|
|
|
|
name = "FiraCode Nerd Font";
|
|
|
|
package = pkgs.nerdfonts.override {fonts = ["FiraCode"];};
|
|
|
|
}
|
|
|
|
];
|
|
|
|
extraConfig = "font-size=14";
|
|
|
|
# extraOptions = "--term xterm-256color";
|
|
|
|
extraOptions = generateOptions {
|
|
|
|
xkb-layout = config.services.xserver.xkb.layout;
|
|
|
|
xkb-variant = config.services.xserver.xkb.variant;
|
|
|
|
|
|
|
|
palette = "custom";
|
|
|
|
palette-foreground = hexToOpt "#ebdbb2";
|
|
|
|
palette-background = hexToOpt "#282828";
|
|
|
|
palette-black = hexToOpt "#282828";
|
|
|
|
palette-red = hexToOpt "#cc241d";
|
|
|
|
palette-green = hexToOpt "#98971a";
|
|
|
|
palette-yellow = hexToOpt "#d79921";
|
|
|
|
palette-blue = hexToOpt "#458588";
|
|
|
|
palette-magenta = hexToOpt "#b16286";
|
|
|
|
palette-cyan = hexToOpt "#689d6a";
|
|
|
|
palette-light-grey = hexToOpt "#a89984";
|
|
|
|
palette-dark-grey = hexToOpt "#928374";
|
|
|
|
palette-light-red = hexToOpt "#fb4934";
|
|
|
|
palette-light-green = hexToOpt "#b8bb26";
|
|
|
|
palette-light-yellow = hexToOpt "#fabd2f";
|
|
|
|
palette-light-blue = hexToOpt "#83a598";
|
|
|
|
palette-light-magenta = hexToOpt "#d3869b";
|
|
|
|
palette-light-cyan = hexToOpt "#8ec07c";
|
|
|
|
palette-white = hexToOpt "#ebdbb2";
|
|
|
|
};
|
|
|
|
hwRender = true;
|
|
|
|
};
|
|
|
|
}
|