Skip to content

Commit d5283b0

Browse files
committed
nixos-modules/host: add option microvm.host.useNotifySockets
1 parent a439229 commit d5283b0

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

nixos-modules/host/default.nix

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,17 @@ in
1717
'';
1818
};
1919

20+
host.useNotifySockets = mkOption {
21+
type = types.bool;
22+
default = false;
23+
description = ''
24+
Enable if all your MicroVMs run with a Hypervisor that sends readiness notification over a VSOCK.
25+
26+
If one of your MicroVMs doesn't do this, its systemd service
27+
will not start up successfully.
28+
'';
29+
};
30+
2031
vms = mkOption {
2132
type = with types; attrsOf (submodule ({ config, name, ... }: {
2233
options = {
@@ -235,7 +246,10 @@ in
235246
# we also have to include a trigger here.
236247
restartTriggers = [guestConfig.system.build.toplevel];
237248
overrideStrategy = "asDropin";
238-
serviceConfig.Type = lib.mkIf guestConfig.microvm.declaredRunner.supportsNotifySocket "notify";
249+
serviceConfig.Type =
250+
if guestConfig.microvm.declaredRunner.supportsNotifySocket
251+
then "notify"
252+
else "simple";
239253
};
240254
"microvm-tap-interfaces@${name}" = {
241255
serviceConfig.X-RestartIfChanged = [ "" microvmConfig.restartIfChanged ];
@@ -436,7 +450,10 @@ in
436450
rm booted
437451
'';
438452
serviceConfig = {
439-
Type = "simple";
453+
Type =
454+
if config.microvm.host.useNotifySockets
455+
then "notify"
456+
else "simple";
440457
WorkingDirectory = "${stateDir}/%i";
441458
ExecStart = "${stateDir}/%i/current/bin/microvm-run";
442459
ExecStop = "${stateDir}/%i/booted/bin/microvm-shutdown";

0 commit comments

Comments
 (0)