For a while I’ve been using the config at this guide to automatically log in a user on a NixOS setup running on a Raspberry Pi. Switching from stable 21.05 to unstable makes it stop working. journalctl -u shows the exact same things it normally does (“Started Autologin at the TTY1.”, “pam_unix(login:session): session opened for user nixos(uid=1000) by LOGIN(uid=0)”), but instead of automatically logging in I simply get a normal login prompt. systemctl status gives the following on unstable
● autovt@tty1.service - Autologin at the TTY1
Loaded: loaded (/etc/systemd/system/autovt@tty1.service; enabled; vendor preset: enabled)
Drop-In: /nix/store/dqggadk7jwkaxhbz1hnywliv3ggi9c5f-system-units/autovt@.service.d
└─overrides.conf
Active: active (running) since Thu 2021-09-30 22:30:39 UTC; 27s ago
Main PID: 829 (login)
IP: 0B in, 0B out
IO: 1.5M read, 0B written
Tasks: 0 (limit: 9537)
Memory: 2.0M
CPU: 17ms
CGroup: /system.slice/system-autovt.slice/autovt@tty1.service
‣ 829 /nix/store/3srhn7p8d5h7w2jz19nz75qvqbwc76ln-shadow-4.8.1/bin/login -- "" "" "" "" "" ""
when the same configuration on 21.05 gives the following
● autovt@tty1.service - Autologin at the TTY1
Loaded: loaded (/nix/store/d1iky3cy9q58rn8y8gpv3wx3xvidzkps-unit-autovt-tty1.service/autovt@tty1.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2021-09-30 22:26:57 UTC; 1min 13s ago
Main PID: 838 (login)
IP: 0B in, 0B out
IO: 1.5M read, 4.0K written
Tasks: 0 (limit: 9542)
Memory: 2.0M
CPU: 7ms
CGroup: /system.slice/system-autovt.slice/autovt@tty1.service
‣ 838 /nix/store/61z6l8p3f14hgz29j607bg1d37sn5d86-shadow-4.8.1/bin/login -f
It seems to me like the issue might be caused by 21.05 generating autovt@tty1 as a service all its own, while unstable creates it as a “drop-in” override for the standard autovt service, or that the issue might be caused by 21.05 correctly generating the .service’s Exec line, while the unstable fails to compile the arguments the .nix gives it.
I’m able to reproduce this with a minimal configuration.nix in a virtual machine, so it’s not any RPi specific weirdness. The .nix files I used for that test are below. util-linux is version 2.36.2 on both 21.05 and unstable, and the same goes for shadow (v 4.8.1). Was there a change to systemd or how nix compiles the configuration that makes this method no longer work?
configuration.nix
{ config, pkgs, ... }:
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
];
# This is the autologin service
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 nixos --noclear %I $TERM"
];
Restart = "always";
Type = "idle";
};
# Use the GRUB 2 boot loader.
boot.loader.grub.enable = true;
boot.loader.grub.version = 2;
boot.loader.grub.device = "/dev/vda"; # or "nodev" for efi only
# The global useDHCP flag is deprecated, therefore explicitly set to false here.
# Per-interface useDHCP will be mandatory in the future, so this generated config
# replicates the default behaviour.
networking.useDHCP = false;
networking.interfaces.enp1s0.useDHCP = true;
# Define a user account. Don't forget to set a password with ‘passwd’.
users.users.nixos = {
isNormalUser = true;
extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user.
};
# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
# on your system were taken. It‘s perfectly fine and recommended to leave
# this value at the release version of the first install of this system.
# Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "21.05"; # Did you read the comment?
}
hardware-configuration.nix
# Do not modify this file! It was generated by ‘nixos-generate-config’
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{
imports =
[ (modulesPath + "/profiles/qemu-guest.nix")
];
boot.initrd.availableKernelModules = [ "ahci" "xhci_pci" "virtio_pci" "sr_mod" "virtio_blk" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ ];
boot.extraModulePackages = [ ];
fileSystems."/" =
{ device = "/dev/disk/by-uuid/c6444cd7-2265-43e8-be39-c9a3cc9c717d";
fsType = "ext4";
};
swapDevices = [ ];
}