nixosTests.autosuspend: init

This commit is contained in:
Anthony Roussel
2026-02-15 21:32:46 +01:00
parent 3b636d180f
commit 33befa88a1
3 changed files with 36 additions and 0 deletions

View File

@@ -257,6 +257,7 @@ in
authelia = runTest ./authelia.nix;
auto-cpufreq = runTest ./auto-cpufreq.nix;
autobrr = runTest ./autobrr.nix;
autosuspend = runTest ./autosuspend.nix;
avahi = runTest {
imports = [ ./avahi.nix ];
_module.args.networkd = false;

View File

@@ -0,0 +1,30 @@
{ lib, pkgs, ... }:
{
name = "autosuspend";
meta.maintainers = [ lib.maintainers.anthonyroussel ];
nodes = {
machine = {
services.autosuspend = {
enable = true;
settings = {
interval = 5;
idle_time = 5;
suspend_cmd = "${pkgs.coreutils}/bin/touch /tmp/suspended";
};
# Return exit code 1 to trigger suspend
checks.ExternalCommand.command = "exit 1";
};
};
};
testScript = ''
start_all()
machine.wait_for_unit("autosuspend.service")
machine.wait_for_file("/tmp/suspended")
'';
}

View File

@@ -2,6 +2,7 @@
lib,
dbus,
fetchFromGitHub,
nixosTests,
python3,
sphinxHook,
withDocs ? true,
@@ -87,6 +88,10 @@ python3.pkgs.buildPythonApplication (finalAttrs: {
"test_multiple_sessions"
];
passthru.tests = {
inherit (nixosTests) autosuspend;
};
meta = {
description = "Daemon to automatically suspend and wake up a system";
homepage = "https://autosuspend.readthedocs.io";