Loading nixos/doc/manual/development/unit-handling.section.md +10 −5 Original line number Diff line number Diff line Loading @@ -58,11 +58,16 @@ checks: before the activation script is run. This behavior is different when the service is socket-activated, as outlined in the following steps. - The last thing that is taken into account is whether the unit is a service and socket-activated. If `X-StopIfChanged` is **not** set, the service is **restart**ed with the others. If it is set, both the service and the socket are **stop**ped and the socket is **start**ed, leaving socket activation to start the service when it's needed. - The last thing that is taken into account is whether the unit is a service and socket-activated. A correspondence between a `.service` and its `.socket` unit is detected automatically, but services can **opt out** of that detection by setting `X-NotSocketActivated` to `yes` in their `[Service]` section. Otherwise, if `X-StopIfChanged` is **not** set, the service is **restart**ed with the others. If it is set, both the service and the socket are **stop**ped and the socket is **start**ed, leaving socket activation to start the service when it's needed. ## Sysinit reactivation {#sec-sysinit-reactivation} Loading nixos/lib/systemd-lib.nix +3 −0 Original line number Diff line number Diff line Loading @@ -579,6 +579,9 @@ in rec { '' else "") + optionalString (def ? stopIfChanged && !def.stopIfChanged) '' X-StopIfChanged=false '' + optionalString (def ? notSocketActivated && def.notSocketActivated) '' X-NotSocketActivated=true '' + attrsToSection def.serviceConfig); }; Loading nixos/lib/systemd-unit-options.nix +12 −0 Original line number Diff line number Diff line Loading @@ -535,6 +535,18 @@ in rec { ''; }; notSocketActivated = mkOption { type = types.bool; default = false; description = '' If set, a changed unit is never assumed to be socket-activated on configuration switch, even if it might have associated socket units. Instead, the unit will be restarted (or stopped/started) as if it had no associated sockets. ''; }; startAt = mkOption { type = with types; either str (listOf str); default = []; Loading nixos/modules/services/hardware/udev.nix +4 −4 Original line number Diff line number Diff line Loading @@ -459,10 +459,10 @@ in fi ''; systemd.services.systemd-udevd = { restartTriggers = [ config.environment.etc."udev/rules.d".source ]; systemd.services.systemd-udevd = { restartTriggers = [ config.environment.etc."udev/rules.d".source ]; notSocketActivated = true; }; }; imports = [ Loading nixos/modules/system/activation/switch-to-configuration.pl +7 −0 Original line number Diff line number Diff line Loading @@ -544,6 +544,13 @@ sub handle_modified_unit { ## no critic(Subroutines::ProhibitManyArgs, Subroutin } } if (parse_systemd_bool(\%new_unit_info, "Service", "X-NotSocketActivated", 0)) { # If the unit explicitly opts out of socket # activation, restart it as if it weren't (but do # restart its sockets, that's fine): $socket_activated = 0; } # If the unit is not socket-activated, record # that this unit needs to be started below. # We write this to a file to ensure that the Loading Loading
nixos/doc/manual/development/unit-handling.section.md +10 −5 Original line number Diff line number Diff line Loading @@ -58,11 +58,16 @@ checks: before the activation script is run. This behavior is different when the service is socket-activated, as outlined in the following steps. - The last thing that is taken into account is whether the unit is a service and socket-activated. If `X-StopIfChanged` is **not** set, the service is **restart**ed with the others. If it is set, both the service and the socket are **stop**ped and the socket is **start**ed, leaving socket activation to start the service when it's needed. - The last thing that is taken into account is whether the unit is a service and socket-activated. A correspondence between a `.service` and its `.socket` unit is detected automatically, but services can **opt out** of that detection by setting `X-NotSocketActivated` to `yes` in their `[Service]` section. Otherwise, if `X-StopIfChanged` is **not** set, the service is **restart**ed with the others. If it is set, both the service and the socket are **stop**ped and the socket is **start**ed, leaving socket activation to start the service when it's needed. ## Sysinit reactivation {#sec-sysinit-reactivation} Loading
nixos/lib/systemd-lib.nix +3 −0 Original line number Diff line number Diff line Loading @@ -579,6 +579,9 @@ in rec { '' else "") + optionalString (def ? stopIfChanged && !def.stopIfChanged) '' X-StopIfChanged=false '' + optionalString (def ? notSocketActivated && def.notSocketActivated) '' X-NotSocketActivated=true '' + attrsToSection def.serviceConfig); }; Loading
nixos/lib/systemd-unit-options.nix +12 −0 Original line number Diff line number Diff line Loading @@ -535,6 +535,18 @@ in rec { ''; }; notSocketActivated = mkOption { type = types.bool; default = false; description = '' If set, a changed unit is never assumed to be socket-activated on configuration switch, even if it might have associated socket units. Instead, the unit will be restarted (or stopped/started) as if it had no associated sockets. ''; }; startAt = mkOption { type = with types; either str (listOf str); default = []; Loading
nixos/modules/services/hardware/udev.nix +4 −4 Original line number Diff line number Diff line Loading @@ -459,10 +459,10 @@ in fi ''; systemd.services.systemd-udevd = { restartTriggers = [ config.environment.etc."udev/rules.d".source ]; systemd.services.systemd-udevd = { restartTriggers = [ config.environment.etc."udev/rules.d".source ]; notSocketActivated = true; }; }; imports = [ Loading
nixos/modules/system/activation/switch-to-configuration.pl +7 −0 Original line number Diff line number Diff line Loading @@ -544,6 +544,13 @@ sub handle_modified_unit { ## no critic(Subroutines::ProhibitManyArgs, Subroutin } } if (parse_systemd_bool(\%new_unit_info, "Service", "X-NotSocketActivated", 0)) { # If the unit explicitly opts out of socket # activation, restart it as if it weren't (but do # restart its sockets, that's fine): $socket_activated = 0; } # If the unit is not socket-activated, record # that this unit needs to be started below. # We write this to a file to ensure that the Loading