From 514c05ee4759a559e4aadbbe861be0bfd16f62ca Mon Sep 17 00:00:00 2001 From: Erik Arvstedt Date: Sat, 22 Oct 2022 19:37:46 +0200 Subject: [PATCH] tests/vmWithoutTests: poweroff on shell exit This allows quitting the VM with Ctrl-D like in the minimal example VM. --- test/lib/make-test.nix | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/test/lib/make-test.nix b/test/lib/make-test.nix index be8c652..7fce27c 100644 --- a/test/lib/make-test.nix +++ b/test/lib/make-test.nix @@ -97,12 +97,10 @@ name: testConfig: # Avoid lengthy build of the nixos manual documentation.nixos.enable = false; - # Provide a shortcut for instant poweroff from within the machine - environment.systemPackages = with pkgs; [ - (lowPrio (writeScriptBin "q" '' - echo o >/proc/sysrq-trigger - '')) - ]; + # Power off VM when the user exits the shell + systemd.services."serial-getty@".preStop = '' + echo o >/proc/sysrq-trigger + ''; system.stateVersion = lib.mkDefault config.system.nixos.release; })).config.system.build.vm;