anchor.diff:    ###### implementation
   
     config = mkIf cfg.enable {
  -
  -    jobs = listToAttrs (map (c: nameValuePair "openvpn-${cfg.id}" (makeOpenVPNJob c)) cfg.servers);
  -  
  +    jobs = listToAttrs (mapAttrsFlatten (name: value: nameValuePair "openvpn-${name}" (makeOpenVPNJob value name)) cfg.servers);
     };
     
   }
  
positive.code: 
    PATH = "${pkgs.iptables}/sbin:${pkgs.coreutils}/bin:${pkgs.iproute}/sbin:${pkgs.nettools}/sbin";
  
    makeOpenVPNJob = cfg :
      let
        upScript = ''
          #!/bin/sh
          exec &> /var/log/openvpn-${cfg.id}-up
          PATH=${PATH}
          ${cfg.up}
        '';
        downScript = ''
          #!/bin/sh
          exec &> /var/log/openvpn-${cfg.id}-down
          PATH=${PATH}
          ${cfg.down}
        '';
        configFile = pkgs.writeText "openvpn-config-${cfg.id}"
          ''
            ${if cfg ? up || cfg ? down then "script-security 2" else ""}
            ${cfg.config}
            ${if cfg ? up then "up ${pkgs.writeScript "openvpn-${cfg.id}-up" upScript}" else "" }
            ${if cfg ? down then "down ${pkgs.writeScript "openvpn-${cfg.id}-down" downScript}" else "" }
          '';
      in {
        description = "OpenVPN-${cfg.id}";
  
        startOn = "network-interfaces/started";
        stopOn = "network-interfaces/stop";
  
negative.code: 
        script =
          ''
            exec &> /var/log/openvpn-${name}
            ${config.system.sbin.modprobe} tun || true
            ${openvpn}/sbin/openvpn --config ${configFile}
          '';
      };
  
    openvpnInstanceOptions = {
  
      config = mkOption {
        type = types.string;
        description = ''
          config of this openvpn instance
        '';
      };
      up = mkOption {
        default = "";
        type = types.string;
        description = ''
          script which is run when server instance starts up succesfully.
          Use it to setup firewall and routing
        '';
      };
      down = mkOption {
        default = "";
        type = types.string;
        description = ''
          script which is run when server instance shuts down
          Usually this reverts what up has done
        '';
      };
  
    };
  
  in
    
  