NixOS provide services.mingetty.autologinUser
option, but it can’t be used for the specific TTY.
TTY1 and user “guest”:
systemd.services."autovt@tty1".description = "Autologin at the TTY1";
systemd.services."autovt@tty1".after = [ "systemd-logind.service" ]; # without it user session not started and xorg can't be run from this tty
systemd.services."autovt@tty1".wantedBy = [ "multi-user.target" ];
systemd.services."autovt@tty1".serviceConfig =
{ ExecStart = [
"" # override upstream default with an empty ExecStart
"@${pkgs.utillinux}/sbin/agetty agetty --login-program ${pkgs.shadow}/bin/login --autologin guest --noclear %I $TERM"
];
Restart = "always";
Type = "idle";
};
TTY1 and user “guest”:
systemd.targets."autologin-tty1".description = "Final";
systemd.targets."autologin-tty1".requires = [ "multi-user.target" ];
systemd.targets."autologin-tty1".after = [ "multi-user.target" ];
systemd.targets."autologin-tty1".unitConfig = { AllowIsolate="yes"; };
systemd.services."supress-kernel-logging".description = "Suppress kernel logging to the console";
systemd.services."supress-kernel-logging".after = [ "multi-user.target" ];
systemd.services."supress-kernel-logging".wantedBy = [ "autologin-tty1.target" ];
systemd.services."supress-kernel-logging".serviceConfig =
{ ExecStart = [
"${pkgs.utillinux}/sbin/dmesg -n 1"
];
Type = "oneshot";
};
systemd.services."autovt@tty1".description = "Autologin on TTY1";
systemd.services."autovt@tty1".after = [ "supress-kernel-logging.service" ];
systemd.services."autovt@tty1".wantedBy = [ "autologin-tty1.target" ];
systemd.services."autovt@tty1".restartIfChanged = false;
systemd.services."autovt@tty1".serviceConfig =
{ ExecStart = [
"" # override upstream default with an empty ExecStart
"@${pkgs.utillinux}/sbin/agetty agetty --login-program ${pkgs.shadow}/bin/login --autologin guest --noclear %I $TERM"
];
Restart = "always";
Type = "idle";
};
https://github.com/a-irs/infra/blob/f73bf14e654df1e0ad9b4a5c1e5c72d0649ac5d6/nixos/etc/conf.d/workstation.nix#L12 https://github.com/coreyoconnor/nix_configs/blob/9aeb6f0ad4a707f0d3f89177774a532c880d3b6a/status-tty.nix#L23 https://web.archive.org/web/20160325165924/https://www.mauras.ch/systemd-run-it-last.html
This didn't work for me because NixOS creates
[email protected]/overrides.conf
, which hasExecStart
, which overrides the one in the"autovt@tty1"
unit created here.The following worked for me instead: