nixos-configuration/autologin.nix
2020-08-27 13:08:35 +02:00

24 lines
861 B
Nix

{ config, pkgs, ... }:
let cfg = config.autologin;
in
{
options = {
autologin.username = pkgs.lib.mkOption {
description = "Username of user to be automatically logged in at tty1";
};
};
config = {
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 '${cfg.username}' --noclear %I $TERM"
];
Restart = "always";
Type = "idle";
};
};
}