Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)

Merge pull request #43682 from primeos/never-stop-system.slice

nixos/switch-to-configuration: Never stop system.slice

authored by Michael Weiss and committed by GitHub 01cfa808 0fa2cbf5

+18
+18
nixos/modules/system/activation/switch-to-configuration.pl
··· 166 166 167 167 if (-e $prevUnitFile && ($state->{state} eq "active" || $state->{state} eq "activating")) { 168 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 + } 169 187 my $unitInfo = parseUnit($prevUnitFile); 170 188 $unitsToStop{$unit} = 1 if boolIsTrue($unitInfo->{'X-StopOnRemoval'} // "yes"); 171 189 }