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") def verifyDeviceIDSet(machine, expectedDevice): machine.succeed( '(( "$(nix eval --raw -f "" config.services.syncthing.declarative.devices.%s.id | wc -c)" == 63 ))' % expectedDevice ) initialConfiguration = "${configuration}" configurationWithDeviceIDs = ( "${configurationWithDeviceIDs}" ) setConfig(a, initialConfiguration) a.wait_for_unit("syncthing-autoregister.service") setConfig(a, configurationWithDeviceIDs) verifyDeviceIDSet(a, "a") ''; })