nixpkgs-suyu/nixos/modules/services/wayland/cage.nix
Florian Klink 962e15aebc nixos: remove StandardOutput=syslog, StandardError=syslog lines
Since systemd 243, docs were already steering users towards using
`journal`:

eedaf7f322

systemd 246 will go one step further, it shows warnings for these units
during bootup, and will [automatically convert these occurences to
`journal`](f3dc6af20f):

> [    6.955976] systemd[1]: /nix/store/hwyfgbwg804vmr92fxc1vkmqfq2k9s17-unit-display-manager.service/display-manager.service:27: Standard output type syslog is obsolete, automatically updating to journal. Please update│······················
 your unit file, and consider removing the setting altogether.

So there's no point of keeping `syslog` here, and it's probably a better
idea to just not set it, due to:

> This setting defaults to the value set with DefaultStandardOutput= in
> systemd-system.conf(5), which defaults to journal.
2020-08-13 18:49:15 +02:00

97 lines
2.6 KiB
Nix

{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.services.cage;
in {
options.services.cage.enable = mkEnableOption "cage kiosk service";
options.services.cage.user = mkOption {
type = types.str;
default = "demo";
description = ''
User to log-in as.
'';
};
options.services.cage.extraArguments = mkOption {
type = types.listOf types.str;
default = [];
defaultText = "[]";
description = "Additional command line arguments to pass to Cage.";
example = ["-d"];
};
options.services.cage.program = mkOption {
type = types.path;
default = "${pkgs.xterm}/bin/xterm";
description = ''
Program to run in cage.
'';
};
config = mkIf cfg.enable {
# The service is partially based off of the one provided in the
# cage wiki at
# https://github.com/Hjdskes/cage/wiki/Starting-Cage-on-boot-with-systemd.
systemd.services."cage-tty1" = {
enable = true;
after = [
"systemd-user-sessions.service"
"plymouth-start.service"
"plymouth-quit.service"
"systemd-logind.service"
"getty@tty1.service"
];
before = [ "graphical.target" ];
wants = [ "dbus.socket" "systemd-logind.service" "plymouth-quit.service"];
wantedBy = [ "graphical.target" ];
conflicts = [ "getty@tty1.service" ];
restartIfChanged = false;
unitConfig.ConditionPathExists = "/dev/tty1";
serviceConfig = {
ExecStart = ''
${pkgs.cage}/bin/cage \
${escapeShellArgs cfg.extraArguments} \
-- ${cfg.program}
'';
User = cfg.user;
IgnoreSIGPIPE = "no";
# Log this user with utmp, letting it show up with commands 'w' and
# 'who'. This is needed since we replace (a)getty.
UtmpIdentifier = "%n";
UtmpMode = "user";
# A virtual terminal is needed.
TTYPath = "/dev/tty1";
TTYReset = "yes";
TTYVHangup = "yes";
TTYVTDisallocate = "yes";
# Fail to start if not controlling the virtual terminal.
StandardInput = "tty-fail";
# Set up a full (custom) user session for the user, required by Cage.
PAMName = "cage";
};
};
security.pam.services.cage.text = ''
auth required pam_unix.so nullok
account required pam_unix.so
session required pam_unix.so
session required ${pkgs.systemd}/lib/security/pam_systemd.so
'';
hardware.opengl.enable = mkDefault true;
systemd.targets.graphical.wants = [ "cage-tty1.service" ];
systemd.defaultUnit = "graphical.target";
};
meta.maintainers = with lib.maintainers; [ matthewbauer flokli ];
}