stylix/modules/kmscon/nixos.nix
Jalil David Salamé Messina 7682713f6a
stylix: add 'stylix.enable' option (#244)
Add a 'stylix.enable' option to enable or disable all Stylix modules in
order to resolve issues similar to [2].

To align with the default 'lib.mkEnableOption' [1] behavior,
'stylix.enable' defaults to 'false'.

BREAKING CHANGE: Stylix is disabled by default. To enable it, use:

    stylix.enable = true;

[1]: https://github.com/NixOS/nixpkgs/blob/23.11/lib/options.nix#L91-L105
[2]: https://github.com/danth/stylix/issues/216

Co-authored-by: Daniel Thwaites <danthwaites30@btinternet.com>
Co-authored-by: Jalil David Salamé Messina <jalil.salame@gmail.com>
Co-authored-by: NAHO <90870942+trueNAHO@users.noreply.github.com>
2024-06-10 11:52:47 +02:00

41 lines
1.4 KiB
Nix

{ config, lib, ... }:
{
options.stylix.targets.kmscon.enable =
config.lib.stylix.mkEnableTarget "the kmscon virtual console" true;
config.services.kmscon = lib.mkIf (config.stylix.enable && config.stylix.targets.kmscon.enable) {
fonts = [config.stylix.fonts.monospace];
extraConfig =
let
formatBase = name:
let
getComponent = comp: config.lib.stylix.colors."${name}-rgb-${comp}";
in
"${getComponent "r"},${getComponent "g"},${getComponent "b"}";
in ''
font-size=${builtins.toString config.stylix.fonts.sizes.terminal}
palette=custom
palette-black=${formatBase "base00"}
palette-red=${formatBase "base08"}
palette-green=${formatBase "base0B"}
palette-yellow=${formatBase "base0A"}
palette-blue=${formatBase "base0D"}
palette-magenta=${formatBase "base0E"}
palette-cyan=${formatBase "base0C"}
palette-light-grey=${formatBase "base05"}
palette-dark-grey=${formatBase "base03"}
palette-light-red=${formatBase "base08"}
palette-light-green=${formatBase "base0B"}
palette-light-yellow=${formatBase "base0A"}
palette-light-blue=${formatBase "base0D"}
palette-light-magenta=${formatBase "base0E"}
palette-light-cyan=${formatBase "base0C"}
palette-white=${formatBase "base07"}
palette-background=${formatBase "base00"}
palette-foreground=${formatBase "base05"}
'';
};
}