nixos/switch-to-configuration: Handle stopped sockets

The previous logic failed to detect that units were socket-activated
when the socket was stopped before switch-to-configuration was run. This
commit fixes that and also starts the socket in question.

Changed files
+7 -6
nixos
modules
system
+7 -6
nixos/modules/system/activation/switch-to-configuration.pl
···
@sockets = ("$baseName.socket");
}
foreach my $socket (@sockets) {
-
if (defined $activePrev->{$socket}) {
-
# Only restart sockets that actually
-
# exist in new configuration
-
if (-e "$out/etc/systemd/system/$socket") {
-
$socketActivated = 1;
-
$unitsToStop->{$unit} = 1;
+
if (-e "$out/etc/systemd/system/$socket") {
+
$socketActivated = 1;
+
$unitsToStop->{$unit} = 1;
+
# If the socket was not running previously,
+
# start it now.
+
if (not defined $activePrev->{$socket}) {
+
$unitsToStart->{$socket} = 1;
}
}
}