at 16.09-beta 2.7 kB view raw
1{ config, pkgs, lib, ... }: 2let 3 inherit (lib) mkOption types mkIf optionalString; 4 5 cfg = config.services.kmscon; 6 7 configDir = pkgs.writeTextFile { name = "kmscon-config"; destination = "/kmscon.conf"; text = cfg.extraConfig; }; 8in { 9 options = { 10 services.kmscon = { 11 enable = mkOption { 12 description = '' 13 Use kmscon as the virtual console instead of gettys. 14 kmscon is a kms/dri-based userspace virtual terminal implementation. 15 It supports a richer feature set than the standard linux console VT, 16 including full unicode support, and when the video card supports drm 17 should be much faster. 18 ''; 19 type = types.bool; 20 default = false; 21 }; 22 23 hwRender = mkOption { 24 description = "Whether to use 3D hardware acceleration to render the console."; 25 type = types.bool; 26 default = false; 27 }; 28 29 extraConfig = mkOption { 30 description = "Extra contents of the kmscon.conf file."; 31 type = types.lines; 32 default = ""; 33 example = "font-size=14"; 34 }; 35 36 extraOptions = mkOption { 37 description = "Extra flags to pass to kmscon."; 38 type = types.separatedString " "; 39 default = ""; 40 example = "--term xterm-256color"; 41 }; 42 }; 43 }; 44 45 config = mkIf cfg.enable { 46 # Largely copied from unit provided with kmscon source 47 systemd.units."kmsconvt@.service".text = '' 48 [Unit] 49 Description=KMS System Console on %I 50 Documentation=man:kmscon(1) 51 After=systemd-user-sessions.service 52 After=plymouth-quit-wait.service 53 After=systemd-logind.service 54 After=systemd-vconsole-setup.service 55 Requires=systemd-logind.service 56 Before=getty.target 57 Conflicts=getty@%i.service 58 OnFailure=getty@%i.service 59 IgnoreOnIsolate=yes 60 ConditionPathExists=/dev/tty0 61 62 [Service] 63 ExecStart=${pkgs.kmscon}/bin/kmscon "--vt=%I" ${cfg.extraOptions} --seats=seat0 --no-switchvt --configdir ${configDir} --login -- ${pkgs.shadow}/bin/login -p 64 UtmpIdentifier=%I 65 TTYPath=/dev/%I 66 TTYReset=yes 67 TTYVHangup=yes 68 TTYVTDisallocate=yes 69 70 X-RestartIfChanged=false 71 ''; 72 73 systemd.units."autovt@.service".unit = pkgs.runCommand "unit" { } 74 '' 75 mkdir -p $out 76 ln -s ${config.systemd.units."kmsconvt@.service".unit}/kmsconvt@.service $out/autovt@.service 77 ''; 78 79 systemd.services.systemd-vconsole-setup.restartIfChanged = false; 80 81 services.kmscon.extraConfig = mkIf cfg.hwRender '' 82 drm 83 hwaccel 84 ''; 85 86 hardware.opengl.enable = mkIf cfg.hwRender true; 87 }; 88}