Unverified Commit 33befa88 authored by Anthony Roussel's avatar Anthony Roussel
Browse files

nixosTests.autosuspend: init

parent 3b636d18
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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;
+30 −0
Original line number Diff line number Diff line
{ 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")
  '';
}
+5 −0
Original line number Diff line number Diff line
@@ -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";