summary refs log tree commit diff
path: root/nixos/modules/virtualisation/containers.nix
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2019-12-30 22:24:37 +0100
committerFlorian Klink <flokli@flokli.de>2019-12-30 22:28:53 +0100
commit90a3908ec333a47232b520d8f5c7f2680f348fea (patch)
tree86ebcfd3bf3f50654818d15cf9db6ad22fd02251 /nixos/modules/virtualisation/containers.nix
parentb38c2839917252989ab4f34cf9254c7e2939329b (diff)
downloadnixpkgs-90a3908ec333a47232b520d8f5c7f2680f348fea.tar
nixpkgs-90a3908ec333a47232b520d8f5c7f2680f348fea.tar.gz
nixpkgs-90a3908ec333a47232b520d8f5c7f2680f348fea.tar.bz2
nixpkgs-90a3908ec333a47232b520d8f5c7f2680f348fea.tar.lz
nixpkgs-90a3908ec333a47232b520d8f5c7f2680f348fea.tar.xz
nixpkgs-90a3908ec333a47232b520d8f5c7f2680f348fea.tar.zst
nixpkgs-90a3908ec333a47232b520d8f5c7f2680f348fea.zip
nixos/containers: use machinectl poweroff
Previously, we were storing the leader pid in a runtime file and
signalled SIGRTMIN+4 manually.

In systemd 219, the `machinectl poweroff` command was introduced, which
does that for us.
Diffstat (limited to 'nixos/modules/virtualisation/containers.nix')
-rw-r--r--nixos/modules/virtualisation/containers.nix15
1 files changed, 1 insertions, 14 deletions
diff --git a/nixos/modules/virtualisation/containers.nix b/nixos/modules/virtualisation/containers.nix
index 09678ce9ea7..02de5801da2 100644
--- a/nixos/modules/virtualisation/containers.nix
+++ b/nixos/modules/virtualisation/containers.nix
@@ -225,12 +225,6 @@ let
           fi
           ${concatStringsSep "\n" (mapAttrsToList renderExtraVeth cfg.extraVeths)}
         fi
-
-        # Get the leader PID so that we can signal it in
-        # preStop. We can't use machinectl there because D-Bus
-        # might be shutting down. FIXME: in systemd 219 we can
-        # just signal systemd-nspawn to do a clean shutdown.
-        machinectl show "$INSTANCE" | sed 's/Leader=\(.*\)/\1/;t;d' > "/run/containers/$INSTANCE.pid"
       ''
   );
 
@@ -715,14 +709,7 @@ in
 
       postStart = postStartScript dummyConfig;
 
-      preStop =
-        ''
-          pid="$(cat /run/containers/$INSTANCE.pid)"
-          if [ -n "$pid" ]; then
-            kill -RTMIN+4 "$pid"
-          fi
-          rm -f "/run/containers/$INSTANCE.pid"
-        '';
+      preStop = "machinectl poweroff $INSTANCE";
 
       restartIfChanged = false;