summary refs log tree commit diff
path: root/nixos/modules/services/ttys
diff options
context:
space:
mode:
authorShea Levy <shea@shealevy.com>2014-01-15 06:58:16 -0500
committerShea Levy <shea@shealevy.com>2014-01-15 08:17:19 -0500
commit48daf624c5647b344e11a36f9a95e5d8134dd9eb (patch)
tree9359a161790a51585cec33443b517dcb89c9834c /nixos/modules/services/ttys
parente5c34ddb55698196c6933349b5df6edea535f784 (diff)
downloadnixlib-48daf624c5647b344e11a36f9a95e5d8134dd9eb.tar
nixlib-48daf624c5647b344e11a36f9a95e5d8134dd9eb.tar.gz
nixlib-48daf624c5647b344e11a36f9a95e5d8134dd9eb.tar.bz2
nixlib-48daf624c5647b344e11a36f9a95e5d8134dd9eb.tar.lz
nixlib-48daf624c5647b344e11a36f9a95e5d8134dd9eb.tar.xz
nixlib-48daf624c5647b344e11a36f9a95e5d8134dd9eb.tar.zst
nixlib-48daf624c5647b344e11a36f9a95e5d8134dd9eb.zip
Add module to use kmscon instead of linux-console for VTs
This required some changes to systemd unit handling:

* Add an option to specify that a unit is just a symlink
* Allow specified units to overwrite systemd-provided ones
* Have gettys.target require autovt@1.service instead of getty@1.service

Signed-off-by: Shea Levy <shea@shealevy.com>
Diffstat (limited to 'nixos/modules/services/ttys')
-rw-r--r--nixos/modules/services/ttys/kmscon.nix64
1 files changed, 64 insertions, 0 deletions
diff --git a/nixos/modules/services/ttys/kmscon.nix b/nixos/modules/services/ttys/kmscon.nix
new file mode 100644
index 000000000000..97fe7a1ca1b8
--- /dev/null
+++ b/nixos/modules/services/ttys/kmscon.nix
@@ -0,0 +1,64 @@
+{ 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 {
+        description = "Use kmscon as the virtual console instead of gettys";
+        type = types.bool;
+        default = false;
+      };
+
+      hwRender = mkOption {
+        description = "Whether to use 3D hardware acceleration to render the console";
+        type = types.bool;
+        default = false;
+      };
+
+      extraConfig = mkOption {
+        description = "Extra contents of the kmscon.conf file";
+        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
+      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
+    '';
+
+    systemd.units."autovt@.service".linkTarget = "${config.systemd.units."kmsconvt@.service".unit}/kmsconvt@.service";
+
+    services.kmscon.extraConfig = mkIf cfg.hwRender ''
+      drm
+      hwaccel
+    '';
+  };
+}