-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nixos/console: fix console setting reloading #113804
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ofborg
bot
added
6.topic: nixos
Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS
8.has: module (update)
This PR changes an existing module in `nixos/`
10.rebuild-darwin: 0
This PR does not cause any packages to rebuild on Darwin
10.rebuild-linux: 1-10
labels
Feb 20, 2021
flokli
reviewed
Feb 20, 2021
+1 for storytelling. |
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 cc54211, 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 f76d2aa), 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]: NixOS@cc54211 [2]: systemd/systemd@f6ba867#diff-84849fddcef81458f69725dc18c6614aade5c4f41a032b6908ebcf1ee6740636 [3]: systemd/systemd@8125e8d [4]: https://web.archive.org/web/20180603130107/https://github.com/NixOS/nixpkgs/issues/22470 [5]: NixOS#81138 [6]: https://web.archive.org/web/20180603130107/https://github.com/NixOS/nixpkgs/issues/22470#issuecomment-330930456 [7]: NixOS@f76d2aa [8]: NixOS#107341
rnhmjoj
force-pushed
the
no-udev-settle-2
branch
from
February 21, 2021 09:32
44b3425
to
9be0529
Compare
Just in case, I tested that reloading doesn't break the desktop sessions with gdm (which used to be a problem in the past). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
6.topic: nixos
Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS
8.has: module (update)
This PR changes an existing module in `nixos/`
10.rebuild-darwin: 0
This PR does not cause any packages to rebuild on Darwin
10.rebuild-linux: 1-10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation for this change
Hope you enjoy long commit messages.
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 NixOS1, 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 time2.
However, the rule bypassed systemd by directly running the binary
systemd-udev-settle
, and the service - though still installed - fellinto 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âs3 by
unlisting it from the installed units.
This, combined with another bug, caused quite a commotion4 in NixOS;
to see why remember the fact that
WantedBy=
in upstream units doesn'twork5, so it had to be added manually in cc54211, 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 realised6 what
the root cause was and fpletz put the final nail7 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 user8 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 f76d2aa), 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?
Things done
console.font
andconsole.packages
trigger a reload