1 import <nixpkgs/nixos/tests/make-test-python.nix> ({ pkgs, lib, ... }:
3 configuration = pkgs.writeText "configuration.nix" ''
6 ${../.}/modules/syncthing-autoregister.nix
7 <nixos/nixos/modules/installer/cd-dvd/channel.nix>
11 openDefaultPorts = true;
14 path = "/tmp/syncthing-auto-register-test-device-ids.nix";
17 environment.systemPackages = with pkgs; [ nix ];
20 initialConfiguration = pkgs.writeText "initial-configuration.nix" ''
22 imports = [ "${configuration}" ];
23 system.activationScripts.installInitialConfiguration = {
26 cp "${configuration}" /etc/nixos/configuration.nix
32 configurationWithDeviceIDs =
33 pkgs.writeText "configuration-with-device-ids.nix" ''
37 /tmp/syncthing-auto-register-test-device-ids.nix
46 a = "${initialConfiguration}";
47 b = "${initialConfiguration}";
51 def setConfig(machine, config):
52 machine.copy_from_host(config, "/etc/nixos/configuration.nix")
55 def verifyDeviceIDSet(machine, expectedDevice):
57 '(( "$(nix eval --raw -f "<nixos/nixos>" config.services.syncthing.declarative.devices.%s.id | wc -c)" == 63 ))'
62 configurationWithDeviceIDs = (
63 "${configurationWithDeviceIDs}"
66 a.wait_for_unit("syncthing-autoregister.service")
67 setConfig(a, configurationWithDeviceIDs)
68 verifyDeviceIDSet(a, "a")