anchor.diff:      maintainers = [ domenkozar eelco rob bobvanderlinden ];
     };
   
  -  nodes =
  -    { tracker =
  -        { pkgs, ... }:
  -        { environment.systemPackages = [ pkgs.transmission ];
  +  nodes = {
  +    tracker = { pkgs, ... }: {
  +      imports = [ transmissionConfig ];
   
  -          virtualisation.vlans = [ 1 ];
  -          networking.interfaces.eth1.ipv4.addresses = [
  -            { address = externalTrackerAddress; prefixLength = 24; }
  -          ];
  +      virtualisation.vlans = [ 1 ];
  +      networking.firewall.enable = false;
  +      networking.interfaces.eth1.ipv4.addresses = [
  +        { address = externalTrackerAddress; prefixLength = 24; }
  +      ];
   
  -          # We need Apache on the tracker to serve the torrents.
  -          services.httpd.enable = true;
  -          services.httpd.virtualHosts = {
  -            "torrentserver.org" = {
  -              adminAddr = "foo@example.org";
  -              documentRoot = "/tmp";
  -            };
  -          };
  -
  -          networking.firewall.enable = false;
  -
  -          services.opentracker.enable = true;
  -
  -          services.transmission.enable = true;
  -          services.transmission.settings.dht-enabled = false;
  -          services.transmission.settings.port-forwaring-enabled = false;
  -        };
  -
  -      router =
  -        { pkgs, nodes, ... }:
  -        { virtualisation.vlans = [ 1 2 ];
  -          networking.nat.enable = true;
  -          networking.nat.internalInterfaces = [ "eth2" ];
  -          networking.nat.externalInterface = "eth1";
  -          networking.firewall.enable = true;
  -          networking.firewall.trustedInterfaces = [ "eth2" ];
  -          networking.interfaces.eth0.ipv4.addresses = [];
  -          networking.interfaces.eth1.ipv4.addresses = [
  -            { address = externalRouterAddress; prefixLength = 24; }
  -          ];
  -          networking.interfaces.eth2.ipv4.addresses = [
  -            { address = internalRouterAddress; prefixLength = 24; }
  -          ];
  -          services.miniupnpd = {
  -            enable = true;
  -            externalInterface = "eth1";
  -            internalIPs = [ "eth2" ];
  -            appendConfig = ''
  -              ext_ip=${externalRouterAddress}
  -            '';
  +      # We need Apache on the tracker to serve the torrents.
  +      services.httpd = {
  +        enable = true;
  +        virtualHosts = {
  +          "torrentserver.org" = {
  +            adminAddr = "foo@example.org";
  +            documentRoot = "/tmp";
             };
           };
  -
  -      client1 =
  -        { pkgs, nodes, ... }:
  -        { environment.systemPackages = [ pkgs.transmission pkgs.miniupnpc ];
  -          virtualisation.vlans = [ 2 ];
  -          networking.interfaces.eth0.ipv4.addresses = [];
  -          networking.interfaces.eth1.ipv4.addresses = [
  -            { address = internalClient1Address; prefixLength = 24; }
  -          ];
  -          networking.defaultGateway = internalRouterAddress;
  -          networking.firewall.enable = false;
  -          services.transmission.enable = true;
  -          services.transmission.settings.dht-enabled = false;
  -          services.transmission.settings.message-level = 3;
  -        };
  -
  -      client2 =
  -        { pkgs, ... }:
  -        { environment.systemPackages = [ pkgs.transmission ];
  -          virtualisation.vlans = [ 1 ];
  -          networking.interfaces.eth0.ipv4.addresses = [];
  -          networking.interfaces.eth1.ipv4.addresses = [
  -            { address = externalClient2Address; prefixLength = 24; }
  -          ];
  -          networking.firewall.enable = false;
  -          services.transmission.enable = true;
  -          services.transmission.settings.dht-enabled = false;
  -          services.transmission.settings.port-forwaring-enabled = false;
  -        };
  +      };
  +      services.opentracker.enable = true;
       };
   
  -  testScript =
  -    { nodes, ... }:
  -    ''
  +    router = { pkgs, nodes, ... }: {
  +      virtualisation.vlans = [ 1 2 ];
  +      networking.nat.enable = true;
  +      networking.nat.internalInterfaces = [ "eth2" ];
  +      networking.nat.externalInterface = "eth1";
  +      networking.firewall.enable = true;
  +      networking.firewall.trustedInterfaces = [ "eth2" ];
  +      networking.interfaces.eth0.ipv4.addresses = [];
  +      networking.interfaces.eth1.ipv4.addresses = [
  +        { address = externalRouterAddress; prefixLength = 24; }
  +      ];
  +      networking.interfaces.eth2.ipv4.addresses = [
  +        { address = internalRouterAddress; prefixLength = 24; }
  +      ];
  +      services.miniupnpd = {
  +        enable = true;
  +        externalInterface = "eth1";
  +        internalIPs = [ "eth2" ];
  +        appendConfig = ''
  +          ext_ip=${externalRouterAddress}
  +        '';
  +      };
  +    };
  +
  +    client1 = { pkgs, nodes, ... }: {
  +      imports = [ transmissionConfig ];
  +      environment.systemPackages = [ pkgs.miniupnpc ];
  +
  +      virtualisation.vlans = [ 2 ];
  +      networking.interfaces.eth0.ipv4.addresses = [];
  +      networking.interfaces.eth1.ipv4.addresses = [
  +        { address = internalClient1Address; prefixLength = 24; }
  +      ];
  +      networking.defaultGateway = internalRouterAddress;
  +      networking.firewall.enable = false;
  +    };
  +
  +    client2 = { pkgs, ... }: {
  +      imports = [ transmissionConfig ];
  +
  +      virtualisation.vlans = [ 1 ];
  +      networking.interfaces.eth0.ipv4.addresses = [];
  +      networking.interfaces.eth1.ipv4.addresses = [
  +        { address = externalClient2Address; prefixLength = 24; }
  +      ];
  +      networking.firewall.enable = false;
  +    };
  +  };
  +
  +  testScript = { nodes, ... }: ''
         start_all()
   
         # Wait for network and miniupnpd.
  
positive.code:           "cmp /tmp/test.tar.bz2 ${file}"
        )
      '';
  
  })
  
negative.code:   externalRouterAddress = "80.100.100.1";
    externalClient2Address = "80.100.100.2";
    externalTrackerAddress = "80.100.100.3";
  
    transmissionConfig = { ... }: {
      environment.systemPackages = [ pkgs.transmission ];
      services.transmission = {
        enable = true;
        settings = {
          dht-enabled = false;
          message-level = 3;
        };
      };
    };
  in
  
  {
  