mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-23 22:20:51 +00:00
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>
This commit is contained in:
parent
e5c34ddb55
commit
48daf624c5
|
@ -214,6 +214,7 @@
|
||||||
./services/torrent/transmission.nix
|
./services/torrent/transmission.nix
|
||||||
./services/ttys/gpm.nix
|
./services/ttys/gpm.nix
|
||||||
./services/ttys/agetty.nix
|
./services/ttys/agetty.nix
|
||||||
|
./services/ttys/kmscon.nix
|
||||||
./services/web-servers/apache-httpd/default.nix
|
./services/web-servers/apache-httpd/default.nix
|
||||||
./services/web-servers/jboss/default.nix
|
./services/web-servers/jboss/default.nix
|
||||||
./services/web-servers/lighttpd/default.nix
|
./services/web-servers/lighttpd/default.nix
|
||||||
|
|
64
nixos/modules/services/ttys/kmscon.nix
Normal file
64
nixos/modules/services/ttys/kmscon.nix
Normal file
|
@ -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
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
|
@ -11,13 +11,16 @@ let
|
||||||
systemd = cfg.package;
|
systemd = cfg.package;
|
||||||
|
|
||||||
makeUnit = name: unit:
|
makeUnit = name: unit:
|
||||||
pkgs.runCommand "unit" { inherit (unit) text; preferLocalBuild = true; }
|
pkgs.runCommand "unit" ({ preferLocalBuild = true; } // optionalAttrs (unit.linkTarget == null) { inherit (unit) text; })
|
||||||
(if unit.enable then ''
|
(if !unit.enable then ''
|
||||||
mkdir -p $out
|
|
||||||
echo -n "$text" > $out/${name}
|
|
||||||
'' else ''
|
|
||||||
mkdir -p $out
|
mkdir -p $out
|
||||||
ln -s /dev/null $out/${name}
|
ln -s /dev/null $out/${name}
|
||||||
|
'' else if unit.linkTarget != null then ''
|
||||||
|
mkdir -p $out
|
||||||
|
ln -s ${unit.linkTarget} $out/${name}
|
||||||
|
'' else ''
|
||||||
|
mkdir -p $out
|
||||||
|
echo -n "$text" > $out/${name}
|
||||||
'');
|
'');
|
||||||
|
|
||||||
upstreamUnits =
|
upstreamUnits =
|
||||||
|
@ -338,7 +341,7 @@ let
|
||||||
done
|
done
|
||||||
|
|
||||||
for i in ${toString (mapAttrsToList (n: v: v.unit) cfg.units)}; do
|
for i in ${toString (mapAttrsToList (n: v: v.unit) cfg.units)}; do
|
||||||
ln -s $i/* $out/
|
ln -fs $i/* $out/
|
||||||
done
|
done
|
||||||
|
|
||||||
for i in ${toString cfg.packages}; do
|
for i in ${toString cfg.packages}; do
|
||||||
|
@ -362,7 +365,7 @@ let
|
||||||
ln -s rescue.target $out/kbrequest.target
|
ln -s rescue.target $out/kbrequest.target
|
||||||
|
|
||||||
mkdir -p $out/getty.target.wants/
|
mkdir -p $out/getty.target.wants/
|
||||||
ln -s ../getty@tty1.service $out/getty.target.wants/
|
ln -s ../autovt@tty1.service $out/getty.target.wants/
|
||||||
|
|
||||||
ln -s ../local-fs.target ../remote-fs.target ../network.target ../nss-lookup.target \
|
ln -s ../local-fs.target ../remote-fs.target ../network.target ../nss-lookup.target \
|
||||||
../nss-user-lookup.target ../swap.target $out/multi-user.target.wants/
|
../nss-user-lookup.target ../swap.target $out/multi-user.target.wants/
|
||||||
|
@ -416,6 +419,11 @@ in
|
||||||
internal = true;
|
internal = true;
|
||||||
description = "The generated unit.";
|
description = "The generated unit.";
|
||||||
};
|
};
|
||||||
|
linkTarget = mkOption {
|
||||||
|
default = null;
|
||||||
|
description = "The file to symlink this target to.";
|
||||||
|
type = types.nullOr types.path;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
config = {
|
config = {
|
||||||
unit = makeUnit name config;
|
unit = makeUnit name config;
|
||||||
|
|
Loading…
Reference in a new issue