From 3087595a6bead1d30cab95a886ef0eba99fa5dae Mon Sep 17 00:00:00 2001 From: Adam Stephens Date: Fri, 27 Oct 2023 18:05:58 -0400 Subject: [PATCH] nixos/incus: preseed should not trigger socket-activation --- nixos/modules/virtualisation/incus.nix | 9 ++++++--- nixos/tests/incus/preseed.nix | 7 +------ nixos/tests/incus/socket-activated.nix | 1 + 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/nixos/modules/virtualisation/incus.nix b/nixos/modules/virtualisation/incus.nix index d7ccc963f6a6..7bf1f67eb3c6 100644 --- a/nixos/modules/virtualisation/incus.nix +++ b/nixos/modules/virtualisation/incus.nix @@ -194,9 +194,11 @@ in systemd.services.incus-preseed = lib.mkIf (cfg.preseed != null) { description = "Incus initialization with preseed file"; - wantedBy = [ "multi-user.target" ]; - requires = [ "incus.service" ]; - after = [ "incus.service" ]; + + wantedBy = ["incus.service"]; + after = ["incus.service"]; + bindsTo = ["incus.service"]; + partOf = ["incus.service"]; script = '' ${cfg.package}/bin/incus admin init --preseed <${ @@ -206,6 +208,7 @@ in serviceConfig = { Type = "oneshot"; + RemainAfterExit = true; }; }; diff --git a/nixos/tests/incus/preseed.nix b/nixos/tests/incus/preseed.nix index 19ec3889093c..47b2d0cd6228 100644 --- a/nixos/tests/incus/preseed.nix +++ b/nixos/tests/incus/preseed.nix @@ -49,13 +49,8 @@ import ../make-test-python.nix ({ pkgs, lib, ... } : }; testScript = '' - def wait_for_preseed(_) -> bool: - _, output = machine.systemctl("is-active incus-preseed.service") - return ("inactive" in output) - machine.wait_for_unit("incus.service") - with machine.nested("Waiting for preseed to complete"): - retry(wait_for_preseed) + machine.wait_for_unit("incus-preseed.service") with subtest("Verify preseed resources created"): machine.succeed("incus profile show nixostest_default") diff --git a/nixos/tests/incus/socket-activated.nix b/nixos/tests/incus/socket-activated.nix index e48831cd3cb3..4d25b26a15f5 100644 --- a/nixos/tests/incus/socket-activated.nix +++ b/nixos/tests/incus/socket-activated.nix @@ -17,6 +17,7 @@ import ../make-test-python.nix ({ pkgs, lib, ... } : # ensure service is not running by default machine.fail("systemctl is-active incus.service") + machine.fail("systemctl is-active incus-preseed.service") # access the socket and ensure the service starts machine.succeed("incus list")