diff options
author | nicoo <nicoo@mur.at> | 2022-04-18 15:42:36 +0200 |
---|---|---|
committer | nicoo <nicoo@mur.at> | 2022-04-18 15:56:34 +0200 |
commit | 11bbb28f8a6906f3402549af1c4bd24061f06ada (patch) | |
tree | 0949ca4cd248bd5f41b2f0d164cd33a28e6c800e /nixos/modules/services/ttys | |
parent | ff9efb0724de5ae0f9db9df2debefced7eb1571d (diff) | |
download | nixlib-11bbb28f8a6906f3402549af1c4bd24061f06ada.tar nixlib-11bbb28f8a6906f3402549af1c4bd24061f06ada.tar.gz nixlib-11bbb28f8a6906f3402549af1c4bd24061f06ada.tar.bz2 nixlib-11bbb28f8a6906f3402549af1c4bd24061f06ada.tar.lz nixlib-11bbb28f8a6906f3402549af1c4bd24061f06ada.tar.xz nixlib-11bbb28f8a6906f3402549af1c4bd24061f06ada.tar.zst nixlib-11bbb28f8a6906f3402549af1c4bd24061f06ada.zip |
nixos/kmscon: Add fonts option
Diffstat (limited to 'nixos/modules/services/ttys')
-rw-r--r-- | nixos/modules/services/ttys/kmscon.nix | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/nixos/modules/services/ttys/kmscon.nix b/nixos/modules/services/ttys/kmscon.nix index 4fe720bf044b..e02ab3cb6b32 100644 --- a/nixos/modules/services/ttys/kmscon.nix +++ b/nixos/modules/services/ttys/kmscon.nix @@ -1,6 +1,6 @@ { config, pkgs, lib, ... }: let - inherit (lib) mkOption types mkIf; + inherit (lib) mapAttrs mkIf mkOption optional optionals types; cfg = config.services.kmscon; @@ -28,6 +28,19 @@ in { default = false; }; + fonts = mkOption { + description = "Fonts used by kmscon, in order of priority."; + default = null; + example = lib.literalExpression ''[ { name = "Source Code Pro"; package = pkgs.source-code-pro; } ]''; + type = with types; + let fontType = submodule { + options = { + name = mkOption { type = str; description = "Font name, as used by fontconfig."; }; + package = mkOption { type = package; description = "Package providing the font."; }; + }; + }; in nullOr (nonEmptyListOf fontType); + }; + extraConfig = mkOption { description = "Extra contents of the kmscon.conf file."; type = types.lines; @@ -87,11 +100,17 @@ in { systemd.services.systemd-vconsole-setup.enable = false; - services.kmscon.extraConfig = mkIf cfg.hwRender '' - drm - hwaccel - ''; + services.kmscon.extraConfig = + let + render = optionals cfg.hwRender [ "drm" "hwaccel" ]; + fonts = optional (cfg.fonts != null) "font-name=${lib.concatMapStringsSep ", " (f: f.name) cfg.fonts}"; + in lib.concatStringsSep "\n" (render ++ fonts); hardware.opengl.enable = mkIf cfg.hwRender true; + + fonts = mkIf (cfg.fonts != null) { + fontconfig.enable = true; + fonts = map (f: f.package) cfg.fonts; + }; }; } |