From aeb75b3b694850cb93866d417661081014e09279 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janne=20He=C3=9F?= Date: Wed, 13 Apr 2022 12:48:20 +0100 Subject: [PATCH] nixos/stage-1-systemd: Implement hibernation + test --- nixos/modules/system/boot/systemd/initrd.nix | 3 +++ nixos/tests/all-tests.nix | 1 + nixos/tests/hibernate.nix | 6 ++++++ 3 files changed, 10 insertions(+) diff --git a/nixos/modules/system/boot/systemd/initrd.nix b/nixos/modules/system/boot/systemd/initrd.nix index 3af124d06a9d..c900348619c0 100644 --- a/nixos/modules/system/boot/systemd/initrd.nix +++ b/nixos/modules/system/boot/systemd/initrd.nix @@ -503,5 +503,8 @@ in { ]; }; }; + + boot.kernelParams = lib.mkIf (config.boot.resumeDevice != "") [ "resume=${config.boot.resumeDevice}" ]; + }; } diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index a1d4e2846570..56629ad77734 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -208,6 +208,7 @@ in # hibernation. This test happens to work on x86_64-linux but # not on other platforms. hibernate = handleTestOn ["x86_64-linux"] ./hibernate.nix {}; + hibernate-systemd-stage-1 = handleTestOn ["x86_64-linux"] ./hibernate.nix { systemdStage1 = true; }; hitch = handleTest ./hitch {}; hledger-web = handleTest ./hledger-web.nix {}; hocker-fetchdocker = handleTest ./hocker-fetchdocker {}; diff --git a/nixos/tests/hibernate.nix b/nixos/tests/hibernate.nix index 032ac6527bc7..7a4b331169a3 100644 --- a/nixos/tests/hibernate.nix +++ b/nixos/tests/hibernate.nix @@ -3,6 +3,7 @@ { system ? builtins.currentSystem , config ? {} , pkgs ? import ../.. { inherit system config; } +, systemdStage1 ? false }: with import ../lib/testing-python.nix { inherit system pkgs; }; @@ -29,6 +30,11 @@ let "/".device = "/dev/vda2"; }; swapDevices = mkOverride 0 [ { device = "/dev/vda1"; } ]; + boot.resumeDevice = mkIf systemdStage1 "/dev/vda1"; + boot.initrd.systemd = mkIf systemdStage1 { + enable = true; + emergencyAccess = true; + }; }; installedSystem = (import ../lib/eval-config.nix { inherit system;