summary refs log tree commit diff
path: root/nixos/modules
diff options
context:
space:
mode:
authornicoo <nicoo@mur.at>2022-04-18 15:42:36 +0200
committernicoo <nicoo@mur.at>2022-04-18 15:56:34 +0200
commit11bbb28f8a6906f3402549af1c4bd24061f06ada (patch)
tree0949ca4cd248bd5f41b2f0d164cd33a28e6c800e /nixos/modules
parentff9efb0724de5ae0f9db9df2debefced7eb1571d (diff)
downloadnixpkgs-11bbb28f8a6906f3402549af1c4bd24061f06ada.tar
nixpkgs-11bbb28f8a6906f3402549af1c4bd24061f06ada.tar.gz
nixpkgs-11bbb28f8a6906f3402549af1c4bd24061f06ada.tar.bz2
nixpkgs-11bbb28f8a6906f3402549af1c4bd24061f06ada.tar.lz
nixpkgs-11bbb28f8a6906f3402549af1c4bd24061f06ada.tar.xz
nixpkgs-11bbb28f8a6906f3402549af1c4bd24061f06ada.tar.zst
nixpkgs-11bbb28f8a6906f3402549af1c4bd24061f06ada.zip
nixos/kmscon: Add fonts option
Diffstat (limited to 'nixos/modules')
-rw-r--r--nixos/modules/services/ttys/kmscon.nix29
1 files changed, 24 insertions, 5 deletions
diff --git a/nixos/modules/services/ttys/kmscon.nix b/nixos/modules/services/ttys/kmscon.nix
index 4fe720bf044..e02ab3cb6b3 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;
+    };
   };
 }