2014-01-15 12:58:16 +01:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
let
|
|
|
|
inherit (pkgs.lib) mkOption types mkIf optionalString;
|
|
|
|
|
|
|
|
cfg = config.services.kmscon;
|
|
|
|
|
|
|
|
configDir = pkgs.writeTextFile { name = "kmscon-config"; destination = "/kmscon.conf"; text = cfg.extraConfig; };
|
|
|
|
in {
|
|
|
|
options = {
|
|
|
|
services.kmscon = {
|
|
|
|
enable = mkOption {
|
2014-01-15 14:14:14 +01:00
|
|
|
description = ''
|
|
|
|
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 {
|
2014-01-15 14:14:14 +01:00
|
|
|
description = "Whether to use 3D hardware acceleration to render the console.";
|
2014-01-15 12:58:16 +01:00
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
extraConfig = mkOption {
|
2014-01-15 14:14:14 +01:00
|
|
|
description = "Extra contents of the kmscon.conf file.";
|
2014-01-15 12:58:16 +01:00
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
|
|
|
example = "font-size=14";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
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]
|
|
|
|
ExecStart=${pkgs.kmscon}/bin/kmscon "--vt=%I" --seats=seat0 --no-switchvt --configdir ${configDir} --login -- ${pkgs.shadow}/bin/login -p
|
|
|
|
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
|
|
|
'';
|
|
|
|
|
2014-03-12 21:00:59 +01:00
|
|
|
systemd.services."autovt@".baseUnit = "${config.systemd.units."kmsconvt@.service".unit}/kmsconvt@.service";
|
2014-01-15 12:58:16 +01:00
|
|
|
|
2014-03-12 21:00:59 +01:00
|
|
|
systemd.services.systemd-vconsole-setup.restartIfChanged = false;
|
2014-01-18 17:17:49 +01:00
|
|
|
|
2014-01-15 12:58:16 +01:00
|
|
|
services.kmscon.extraConfig = mkIf cfg.hwRender ''
|
|
|
|
drm
|
|
|
|
hwaccel
|
|
|
|
'';
|
2014-01-15 14:08:45 +01:00
|
|
|
|
2014-02-08 20:45:28 +01:00
|
|
|
hardware.opengl.enable = mkIf cfg.hwRender true;
|
2014-01-15 12:58:16 +01:00
|
|
|
};
|
|
|
|
}
|