···166167 if (-e $prevUnitFile && ($state->{state} eq "active" || $state->{state} eq "activating")) {
168 if (! -e $newUnitFile || abs_path($newUnitFile) eq "/dev/null") {
000000000000000000169 my $unitInfo = parseUnit($prevUnitFile);
170 $unitsToStop{$unit} = 1 if boolIsTrue($unitInfo->{'X-StopOnRemoval'} // "yes");
171 }
···166167 if (-e $prevUnitFile && ($state->{state} eq "active" || $state->{state} eq "activating")) {
168 if (! -e $newUnitFile || abs_path($newUnitFile) eq "/dev/null") {
169+ # Ignore (i.e. never stop) these units:
170+ if ($unit eq "system.slice") {
171+ # TODO: This can be removed a few months after 18.09 is out
172+ # (i.e. after everyone switched away from 18.03).
173+ # Problem: Restarting (stopping) system.slice would not only
174+ # stop X11 but also most system units/services. We obviously
175+ # don't want this happening to users when they switch from 18.03
176+ # to 18.09 or nixos-unstable.
177+ # Reason: The following change in systemd:
178+ # https://github.com/systemd/systemd/commit/d8e5a9338278d6602a0c552f01f298771a384798
179+ # The commit adds system.slice to the perpetual units, which
180+ # means removing the unit file and adding it to the source code.
181+ # This is done so that system.slice can't be stopped anymore but
182+ # in our case it ironically would cause this script to stop
183+ # system.slice because the unit was removed (and an older
184+ # systemd version is still running).
185+ next;
186+ }
187 my $unitInfo = parseUnit($prevUnitFile);
188 $unitsToStop{$unit} = 1 if boolIsTrue($unitInfo->{'X-StopOnRemoval'} // "yes");
189 }