2014-05-05 20:58:51 +02:00
|
|
|
{ config, pkgs, lib, ... }:
|
2014-01-15 12:58:16 +01:00
|
|
|
let
|
2022-04-18 15:42:36 +02:00
|
|
|
inherit (lib) mapAttrs mkIf mkOption optional optionals types;
|
2014-01-15 12:58:16 +01:00
|
|
|
|
|
|
|
cfg = config.services.kmscon;
|
|
|
|
|
2018-09-29 20:56:34 +02:00
|
|
|
autologinArg = lib.optionalString (cfg.autologinUser != null) "-f ${cfg.autologinUser}";
|
|
|
|
|
2014-01-15 12:58:16 +01:00
|
|
|
configDir = pkgs.writeTextFile { name = "kmscon-config"; destination = "/kmscon.conf"; text = cfg.extraConfig; };
|
|
|
|
in {
|
|
|
|
options = {
|
|
|
|
services.kmscon = {
|
|
|
|
enable = mkOption {
|
2022-07-28 23:19:15 +02:00
|
|
|
description = lib.mdDoc ''
|
2014-01-15 14:14:14 +01:00
|
|
|
Use kmscon as the virtual console instead of gettys.
|
|
|
|
kmscon is a kms/dri-based userspace virtual terminal implementation.
|
|
|
|
It supports a richer feature set than the standard linux console VT,
|
|
|
|
including full unicode support, and when the video card supports drm
|
|
|
|
should be much faster.
|
|
|
|
'';
|
2014-01-15 12:58:16 +01:00
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
hwRender = mkOption {
|
2022-07-28 23:19:15 +02:00
|
|
|
description = lib.mdDoc "Whether to use 3D hardware acceleration to render the console.";
|
2014-01-15 12:58:16 +01:00
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
};
|
|
|
|
|
2022-04-18 15:42:36 +02:00
|
|
|
fonts = mkOption {
|
2022-07-28 23:19:15 +02:00
|
|
|
description = lib.mdDoc "Fonts used by kmscon, in order of priority.";
|
2022-04-18 15:42:36 +02:00
|
|
|
default = null;
|
|
|
|
example = lib.literalExpression ''[ { name = "Source Code Pro"; package = pkgs.source-code-pro; } ]'';
|
|
|
|
type = with types;
|
|
|
|
let fontType = submodule {
|
|
|
|
options = {
|
2022-07-28 23:19:15 +02:00
|
|
|
name = mkOption { type = str; description = lib.mdDoc "Font name, as used by fontconfig."; };
|
|
|
|
package = mkOption { type = package; description = lib.mdDoc "Package providing the font."; };
|
2022-04-18 15:42:36 +02:00
|
|
|
};
|
|
|
|
}; in nullOr (nonEmptyListOf fontType);
|
|
|
|
};
|
|
|
|
|
2014-01-15 12:58:16 +01:00
|
|
|
extraConfig = mkOption {
|
2022-07-28 23:19:15 +02:00
|
|
|
description = lib.mdDoc "Extra contents of the kmscon.conf file.";
|
2014-01-15 12:58:16 +01:00
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
|
|
|
example = "font-size=14";
|
|
|
|
};
|
2015-12-20 14:15:49 +01:00
|
|
|
|
|
|
|
extraOptions = mkOption {
|
2022-07-28 23:19:15 +02:00
|
|
|
description = lib.mdDoc "Extra flags to pass to kmscon.";
|
2015-12-20 14:15:49 +01:00
|
|
|
type = types.separatedString " ";
|
|
|
|
default = "";
|
|
|
|
example = "--term xterm-256color";
|
|
|
|
};
|
2018-09-29 20:56:34 +02:00
|
|
|
|
|
|
|
autologinUser = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
2022-07-28 23:19:15 +02:00
|
|
|
description = lib.mdDoc ''
|
2018-09-29 20:56:34 +02:00
|
|
|
Username of the account that will be automatically logged in at the console.
|
|
|
|
If unspecified, a login prompt is shown as usual.
|
|
|
|
'';
|
|
|
|
};
|
2014-01-15 12:58:16 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
# Largely copied from unit provided with kmscon source
|
|
|
|
systemd.units."kmsconvt@.service".text = ''
|
|
|
|
[Unit]
|
|
|
|
Description=KMS System Console on %I
|
|
|
|
Documentation=man:kmscon(1)
|
|
|
|
After=systemd-user-sessions.service
|
|
|
|
After=plymouth-quit-wait.service
|
|
|
|
After=systemd-logind.service
|
2014-03-12 21:00:59 +01:00
|
|
|
After=systemd-vconsole-setup.service
|
2014-01-15 12:58:16 +01:00
|
|
|
Requires=systemd-logind.service
|
|
|
|
Before=getty.target
|
|
|
|
Conflicts=getty@%i.service
|
|
|
|
OnFailure=getty@%i.service
|
|
|
|
IgnoreOnIsolate=yes
|
|
|
|
ConditionPathExists=/dev/tty0
|
|
|
|
|
|
|
|
[Service]
|
2017-09-21 04:00:00 +02:00
|
|
|
ExecStart=
|
2018-09-29 20:56:34 +02:00
|
|
|
ExecStart=${pkgs.kmscon}/bin/kmscon "--vt=%I" ${cfg.extraOptions} --seats=seat0 --no-switchvt --configdir ${configDir} --login -- ${pkgs.shadow}/bin/login -p ${autologinArg}
|
2014-01-15 12:58:16 +01:00
|
|
|
UtmpIdentifier=%I
|
|
|
|
TTYPath=/dev/%I
|
|
|
|
TTYReset=yes
|
|
|
|
TTYVHangup=yes
|
|
|
|
TTYVTDisallocate=yes
|
2014-01-15 14:52:08 +01:00
|
|
|
|
|
|
|
X-RestartIfChanged=false
|
2014-01-15 12:58:16 +01:00
|
|
|
'';
|
|
|
|
|
2021-02-15 21:52:39 +01:00
|
|
|
systemd.suppressedSystemUnits = [ "autovt@.service" ];
|
|
|
|
systemd.units."kmsconvt@.service".aliases = [ "autovt@.service" ];
|
2014-01-15 12:58:16 +01:00
|
|
|
|
2017-03-01 11:45:33 +01:00
|
|
|
systemd.services.systemd-vconsole-setup.enable = false;
|
2014-01-18 17:17:49 +01:00
|
|
|
|
2022-04-18 15:42:36 +02:00
|
|
|
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);
|
2014-01-15 14:08:45 +01:00
|
|
|
|
2014-02-08 20:45:28 +01:00
|
|
|
hardware.opengl.enable = mkIf cfg.hwRender true;
|
2022-04-18 15:42:36 +02:00
|
|
|
|
|
|
|
fonts = mkIf (cfg.fonts != null) {
|
|
|
|
fontconfig.enable = true;
|
|
|
|
fonts = map (f: f.package) cfg.fonts;
|
|
|
|
};
|
2014-01-15 12:58:16 +01:00
|
|
|
};
|
|
|
|
}
|