nixpkgs/nixos/modules/config
rnhmjoj 9be0529210
nixos/console: fix console setting reloading
It's a dull and boring day, it's cold outside and I'm stuck at home: let
me tell you the story of systemd-vconsole-setup.

In the beginnings of NixOS[1], systemd-vconsole-setup was a powerful
sysinit.target unit, installed and running at boot to set up fonts
keyboard layouts and even colors of the virtual consoles. If needed, the
service would also be restarted after a configuration change, consoles
were happy and everything was good, well, almost.

Since the service had no way to specify the dependency "ttys are ready",
modesetting could sometimes happen *after* systemd-vconsole-setup had
started, leaving the console in a broken state. So abbradar worked
around that by putting a systemd-udev-settle `After=`.

In the meanwhile, probably realizing their mistake, systemd added a
shiny udev rule to start the systemd-udev-settle at the right time[2].
However, the rule bypassed systemd by directly running the binary
`systemd-udev-settle`, and the service - though still installed - fell
into disuse.

Two years would pass before a good samaritan, seeing the poor jobless
systemd-udev-settle service, decided to give it the coup de grâs[3] by
unlisting it from the installed units.
This, combined with another bug, caused quite a commotion[4] in NixOS;
to see why remember the fact that `WantedBy=` in upstream units doesn't
work[5], so it had to be added manually in cc542110, but while systemd
removed it, the NixOS unit continued to install and restart the service,
making a lot of fuss when switching configuration.

After at least thee different tentative fixes, deedrah realised[6] what
the root cause was and fpletz put the final nail[7] in the coffin of
systemd-udev-settle. The service would never see the light of a boot
again, NixOS would not restart it all the time but thanks to udev
consoles would still get their pretty fonts and playful colors.

The En..

..no, wait! You should ask what came of systemd-udev-settle, first.
And why is the service even around if udev is doing all the work?

Udev-settle, like the deceitful snake that he is, laid hidden for years.
He looks innocuous doesn't it? A little hack. Only until it leaves his
den and a poor user[8] drops dead. Obviously, it serves no purpose, as
the service is not part of the boot process anymore, so let's remove it
for good!

About the service, it may not be useful at boot, but it can be started
to pick up changes in vconsole.conf and set the consoles accordingly.
But wait, this doesn't work anymore: the service is never started at
boot (remember f76d2aa6), so switch-to-configuration.pl will not restart
it. Fortunately it can be repaired: here I install a new unit which
does *nothing* on start, but restarts the real service when reloaded.
This perfectly reproduces the original behavior, hopefully without the
original bugs too.

The End?

[1]: cc54211069
[2]: f6ba8671d8 (diff-84849fddcef81458f69725dc18c6614aade5c4f41a032b6908ebcf1ee6740636)
[3]: 8125e8d38e
[4]: https://web.archive.org/web/20180603130107/https://github.com/NixOS/nixpkgs/issues/22470
[5]: https://github.com/NixOS/nixpkgs/issues/81138
[6]: https://web.archive.org/web/20180603130107/https://github.com/NixOS/nixpkgs/issues/22470#issuecomment-330930456
[7]: f76d2aa6e3
[8]: https://github.com/NixOS/nixpkgs/issues/107341
2021-02-21 10:27:34 +01:00
..
fonts treewide: fix double quoted strings in meta.description 2021-01-24 19:56:59 +07:00
gtk gtk-icon-cache: get native gtk3 for icon cache 2020-03-06 00:45:48 -05:00
krb5 nixos/krb5: add list to example configuration 2020-08-25 17:18:56 +02:00
xdg nixos/xdg/portal: fix loading portals from systemd service 2021-01-11 19:22:22 -05:00
appstream.nix nixos/modules: remove trailing whitespace 2020-08-07 14:45:39 +01:00
console.nix nixos/console: fix console setting reloading 2021-02-21 10:27:34 +01:00
debug-info.nix
gnu.nix nixos/modules: stdenv.lib -> lib 2021-01-17 21:40:51 +01:00
i18n.nix treewide: fix double quoted strings in meta.description 2021-01-24 19:56:59 +07:00
iproute2.nix
ldap.nix Merge pull request #98731 from mayflower/ldap-nss-optional 2020-12-12 10:53:39 +01:00
locale.nix
malloc.nix nixos/malloc: fix Scudo 2020-11-17 09:11:31 -05:00
networking.nix treewide: fix double quoted strings in meta.description 2021-01-24 19:56:59 +07:00
no-x-libs.nix beam-packages: move wxSupport arg up to package set, add beam_nox 2021-01-24 21:04:52 +01:00
nsswitch.nix nixos/nsswitch: improve error message 2020-05-11 16:14:51 +02:00
power-management.nix nixos/power-management: always run systemctl of the currently running systemd 2020-05-21 10:28:29 +02:00
pulseaudio.nix treewide: fix double quoted strings in meta.description 2021-01-24 19:56:59 +07:00
qt5.nix nixos/qt5: support adwaita-dark theme 2020-04-05 08:38:08 +03:00
resolvconf.nix nixos/resolvconf: always run systemctl of the currently running systemd 2020-05-21 10:29:22 +02:00
shells-environment.nix
swap.nix utillinux: rename to util-linux 2020-11-24 12:42:06 -05:00
sysctl.nix
system-environment.nix
system-path.nix nufraw: init at 0.43-3 2021-01-07 22:41:34 +01:00
terminfo.nix
unix-odbc-drivers.nix
update-users-groups.pl Merge pull request #41966 from aneeshusa/allow-mutable-shells-for-declarative-users 2020-12-31 02:03:22 +01:00
users-groups.nix Merge pull request #110627 from 4z3/use-real-user-name-for-per-user-packages 2021-02-15 12:45:24 +01:00
vte.nix nixos: add freedesktop/gnome/myself maintainers 2020-04-01 20:53:09 -04:00
zram.nix nixos/zram: add zramSwap.memoryMax option 2020-11-25 13:43:38 +00:00