nixos-containers: Use systemd 231's --notify-ready flag

This commit is contained in:
Eelco Dolstra 2016-07-28 17:21:22 +02:00
parent 42f8df10a2
commit bf3edfbb3c
1 changed files with 4 additions and 10 deletions

View File

@ -32,10 +32,8 @@ let
fi fi
fi fi
# Start the regular stage 1 script, passing the bind-mounted # Start the regular stage 1 script.
# notification socket from the host to allow the container exec "$1"
# systemd to signal readiness to the host systemd.
NOTIFY_SOCKET=/var/lib/private/host-notify exec "$1"
''; '';
system = config.nixpkgs.system; system = config.nixpkgs.system;
@ -326,19 +324,17 @@ in
fi fi
''} ''}
rm -f $root/var/lib/private/host-notify
# Run systemd-nspawn without startup notification (we'll # Run systemd-nspawn without startup notification (we'll
# wait for the container systemd to signal readiness). # wait for the container systemd to signal readiness).
EXIT_ON_REBOOT=1 NOTIFY_SOCKET= \ EXIT_ON_REBOOT=1 \
exec ${config.systemd.package}/bin/systemd-nspawn \ exec ${config.systemd.package}/bin/systemd-nspawn \
--keep-unit \ --keep-unit \
-M "$INSTANCE" -D "$root" $extraFlags \ -M "$INSTANCE" -D "$root" $extraFlags \
$EXTRA_NSPAWN_FLAGS \ $EXTRA_NSPAWN_FLAGS \
--notify-ready=yes \
--bind-ro=/nix/store \ --bind-ro=/nix/store \
--bind-ro=/nix/var/nix/db \ --bind-ro=/nix/var/nix/db \
--bind-ro=/nix/var/nix/daemon-socket \ --bind-ro=/nix/var/nix/daemon-socket \
--bind=/run/systemd/notify:/var/lib/private/host-notify \
--bind="/nix/var/nix/profiles/per-container/$INSTANCE:/nix/var/nix/profiles" \ --bind="/nix/var/nix/profiles/per-container/$INSTANCE:/nix/var/nix/profiles" \
--bind="/nix/var/nix/gcroots/per-container/$INSTANCE:/nix/var/nix/gcroots" \ --bind="/nix/var/nix/gcroots/per-container/$INSTANCE:/nix/var/nix/gcroots" \
--setenv PRIVATE_NETWORK="$PRIVATE_NETWORK" \ --setenv PRIVATE_NETWORK="$PRIVATE_NETWORK" \
@ -404,8 +400,6 @@ in
Type = "notify"; Type = "notify";
NotifyAccess = "all";
# Note that on reboot, systemd-nspawn returns 133, so this # Note that on reboot, systemd-nspawn returns 133, so this
# unit will be restarted. On poweroff, it returns 0, so the # unit will be restarted. On poweroff, it returns 0, so the
# unit won't be restarted. # unit won't be restarted.