import ({ pkgs, lib, ... }: let configuration = pkgs.writeText "configuration.nix" '' { pkgs, ... }: { imports = [ ${../.}/modules/syncthing-autoregister.nix ]; services.syncthing = { enable = true; openDefaultPorts = true; autoRegister = { enable = true; path = "/tmp/syncthing-auto-register-test-device-ids.nix"; }; }; environment.systemPackages = with pkgs; [ nix ]; } ''; configurationWithDeviceIDs = pkgs.writeText "configuration-with-device-ids.nix" '' { imports = [ ${configuration} /tmp/syncthing-auto-register-test-device-ids.nix ]; } ''; in { name = "syncthing"; nodes = { a = "${configuration}"; b = "${configuration}"; }; testScript = '' def setConfig(machine, config): machine.copy_from_host(config, "/etc/nixos/configuration.nix") initialConfiguration = "${configuration}" configurationWithDeviceIDs = ( "${configurationWithDeviceIDs}" ) setConfig(a, initialConfiguration) a.wait_for_unit("syncthing-autoregister.service") setConfig(a, configurationWithDeviceIDs) a.succeed( '(( "$(nix eval --raw -f "" config.services.syncthing.declarative.devices.a.id | wc -c)" == 63 ))' ) ''; })