From 5d4dc437c25655f95abc0be363fb5472556702b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Tue, 17 Jun 2025 19:28:12 +0200 Subject: [PATCH] hello-world: migrate to clan.nixosTests module --- clanServices/hello-world/flake-module.nix | 17 +++--- clanServices/hello-world/tests/vm/default.nix | 53 +++++++------------ 2 files changed, 25 insertions(+), 45 deletions(-) diff --git a/clanServices/hello-world/flake-module.nix b/clanServices/hello-world/flake-module.nix index b3d8d6394..239078ec5 100644 --- a/clanServices/hello-world/flake-module.nix +++ b/clanServices/hello-world/flake-module.nix @@ -14,7 +14,7 @@ in hello-world = module; }; perSystem = - { pkgs, ... }: + { ... }: let # Module that contains the tests # This module adds: @@ -41,15 +41,10 @@ in 2. To run the test nix build .#checks.x86_64-linux.hello-service */ - checks = - # Currently we don't support nixos-integration tests on darwin - lib.optionalAttrs (pkgs.stdenv.isLinux) { - hello-service = import ./tests/vm/default.nix { - inherit module; - inherit self inputs pkgs; - nixosLib = import (self.inputs.nixpkgs + "/nixos/lib") { }; - clan-core = self; - }; - }; + clan.nixosTests.hello-service = { + imports = [ ./tests/vm/default.nix ]; + + clan.modules.hello-service = module; + }; }; } diff --git a/clanServices/hello-world/tests/vm/default.nix b/clanServices/hello-world/tests/vm/default.nix index bddf8a808..8fb4f7b3f 100644 --- a/clanServices/hello-world/tests/vm/default.nix +++ b/clanServices/hello-world/tests/vm/default.nix @@ -1,44 +1,29 @@ { - pkgs, - nixosLib, - clan-core, module, ... }: -nixosLib.runTest ( - { ... }: - { - imports = [ - clan-core.modules.nixosVmTest.clanTest - ]; +{ + name = "hello-service"; - hostPkgs = pkgs; + clan = { + directory = ./.; + inventory = { + machines.peer1 = { }; - name = "hello-service"; - - clan = { - directory = ./.; - modules = { - hello-service = module; - }; - inventory = { - machines.peer1 = { }; - - instances."test" = { - module.name = "hello-service"; - roles.peer.machines.peer1 = { }; - }; + instances."test" = { + module.name = "hello-service"; + roles.peer.machines.peer1 = { }; }; }; + }; - testScript = - { nodes, ... }: - '' - start_all() + testScript = + { nodes, ... }: + '' + start_all() - # peer1 should have the 'hello' file - value = peer1.succeed("cat ${nodes.peer1.clan.core.vars.generators.hello.files.hello.path}") - assert value.strip() == "Hello world from peer1", value - ''; - } -) + # peer1 should have the 'hello' file + value = peer1.succeed("cat ${nodes.peer1.clan.core.vars.generators.hello.files.hello.path}") + assert value.strip() == "Hello world from peer1", value + ''; +}