···166166167167 if (-e $prevUnitFile && ($state->{state} eq "active" || $state->{state} eq "activating")) {
168168 if (! -e $newUnitFile || abs_path($newUnitFile) eq "/dev/null") {
169169+ # Ignore (i.e. never stop) these units:
170170+ if ($unit eq "system.slice") {
171171+ # TODO: This can be removed a few months after 18.09 is out
172172+ # (i.e. after everyone switched away from 18.03).
173173+ # Problem: Restarting (stopping) system.slice would not only
174174+ # stop X11 but also most system units/services. We obviously
175175+ # don't want this happening to users when they switch from 18.03
176176+ # to 18.09 or nixos-unstable.
177177+ # Reason: The following change in systemd:
178178+ # https://github.com/systemd/systemd/commit/d8e5a9338278d6602a0c552f01f298771a384798
179179+ # The commit adds system.slice to the perpetual units, which
180180+ # means removing the unit file and adding it to the source code.
181181+ # This is done so that system.slice can't be stopped anymore but
182182+ # in our case it ironically would cause this script to stop
183183+ # system.slice because the unit was removed (and an older
184184+ # systemd version is still running).
185185+ next;
186186+ }
169187 my $unitInfo = parseUnit($prevUnitFile);
170188 $unitsToStop{$unit} = 1 if boolIsTrue($unitInfo->{'X-StopOnRemoval'} // "yes");
171189 }