From: Scott Worley Date: Mon, 27 Jul 2020 22:40:15 +0000 (-0700) Subject: Avoid race: Install initial configuration statically X-Git-Url: http://git.scottworley.com/syncthing-autoregister/commitdiff_plain/2475b5344ca33d7aad5b57f42310994d60b80ee3?ds=sidebyside Avoid race: Install initial configuration statically --- diff --git a/tests/automatic-enrollment.nix b/tests/automatic-enrollment.nix index 8cbcdc4..1a6b360 100644 --- a/tests/automatic-enrollment.nix +++ b/tests/automatic-enrollment.nix @@ -17,6 +17,18 @@ import ({ pkgs, lib, ... }: environment.systemPackages = with pkgs; [ nix ]; } ''; + initialConfiguration = pkgs.writeText "initial-configuration.nix" '' + { + imports = [ "${configuration}" ]; + system.activationScripts.installInitialConfiguration = { + text = ''' + mkdir -p /etc/nixos + cp "${configuration}" /etc/nixos/configuration.nix + '''; + deps = [ ]; + }; + } + ''; configurationWithDeviceIDs = pkgs.writeText "configuration-with-device-ids.nix" '' { @@ -31,8 +43,8 @@ import ({ pkgs, lib, ... }: name = "syncthing"; nodes = { - a = "${configuration}"; - b = "${configuration}"; + a = "${initialConfiguration}"; + b = "${initialConfiguration}"; }; testScript = '' @@ -47,12 +59,10 @@ import ({ pkgs, lib, ... }: ) - initialConfiguration = "${configuration}" configurationWithDeviceIDs = ( "${configurationWithDeviceIDs}" ) - setConfig(a, initialConfiguration) a.wait_for_unit("syncthing-autoregister.service") setConfig(a, configurationWithDeviceIDs) verifyDeviceIDSet(a, "a")