From 9b6f9e462436c27dade3f263a337d67625f27b32 Mon Sep 17 00:00:00 2001 From: aszlig Date: Sun, 4 Jun 2023 23:14:07 +0200 Subject: [PATCH] nixos/tests/taskserver: Fix build The test fails because the way the configuration switch was implemented back then was by using a dummy configuration and simply activating that dummy configuration from within the test script. Nowadays, this doesn't work anymore and fails to typecheck because the dummy "newServer" will inherit the same value for networking.hostName, which in turn will generate two attributes for "server": > testScriptWithTypes:43: error: Name "server" already defined on line 43 > [no-redef] > client1: Machine; client2: Machine; server: Machine; server: Machine; Fortunately, we don't need to do workarounds like this anymore and there is the "specialisation" option, which allows to do this in a less ugly way (and it also works with mypy). Signed-off-by: aszlig --- nixos/tests/taskserver.nix | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/nixos/tests/taskserver.nix b/nixos/tests/taskserver.nix index b2bd421e231f..254bc8822f89 100644 --- a/nixos/tests/taskserver.nix +++ b/nixos/tests/taskserver.nix @@ -69,23 +69,14 @@ in { testOrganisation.users = [ "alice" "foo" ]; anotherOrganisation.users = [ "bob" ]; }; - }; - # New generation of the server with manual config - newServer = { lib, nodes, ... }: { - imports = [ server ]; - services.taskserver.pki.manual = { - ca.cert = snakeOil.cacert; - server.cert = snakeOil.cert; - server.key = snakeOil.key; - server.crl = snakeOil.crl; - }; - # This is to avoid assigning a different network address to the new - # generation. - networking = lib.mapAttrs (lib.const lib.mkForce) { - interfaces.eth1.ipv4 = nodes.server.config.networking.interfaces.eth1.ipv4; - inherit (nodes.server.config.networking) - hostName primaryIPAddress extraHosts; + specialisation.manual-config.configuration = { + services.taskserver.pki.manual = { + ca.cert = snakeOil.cacert; + server.cert = snakeOil.cert; + server.key = snakeOil.key; + server.crl = snakeOil.crl; + }; }; }; @@ -103,7 +94,8 @@ in { testScript = { nodes, ... }: let cfg = nodes.server.config.services.taskserver; portStr = toString cfg.listenPort; - newServerSystem = nodes.newServer.config.system.build.toplevel; + specialisations = "${nodes.server.system.build.toplevel}/specialisation"; + newServerSystem = "${specialisations}/manual-config"; switchToNewServer = "${newServerSystem}/bin/switch-to-configuration test"; in '' from shlex import quote