anchor.diff:      let
         os = val:
           optionalString (val != null) "${val}";
  -      os' = prefixx: val:
  -        optionalString (val != null) (prefixx + "${val}");
  +      os' = prefix: val:
  +        optionalString (val != null) (prefix + "${val}");
         flatten = key: value:
           "&${key}=${value}";
       in
  -      "-s ${opt.type}://" + os opt.location + "?" + os' "name=" name
  -        + concatStrings (mapAttrsToList flatten opt.query);
  +      "--stream.stream=\"${opt.type}://" + os opt.location + "?" + os' "name=" name
  +        + concatStrings (mapAttrsToList flatten opt.query) + "\"";
   
     optionalNull = val: ret:
       optional (val != null) ret;
   
     optionString = concatStringsSep " " (mapAttrsToList streamToOption cfg.streams
  -             ++ ["-p ${toString cfg.port}"]
  -             ++ ["--controlPort ${toString cfg.controlPort}"]
  -             ++ optionalNull cfg.sampleFormat "--sampleFormat ${cfg.sampleFormat}"
  -             ++ optionalNull cfg.codec "-c ${cfg.codec}"
  -             ++ optionalNull cfg.streamBuffer "--streamBuffer ${cfg.streamBuffer}"
  -             ++ optionalNull cfg.buffer "-b ${cfg.buffer}"
  -             ++ optional cfg.sendToMuted "--sendToMuted");
  +    # global options
  +    ++ [ "--stream.bind_to_address ${cfg.listenAddress}" ]
  +    ++ [ "--stream.port ${toString cfg.port}" ]
  +    ++ optionalNull cfg.sampleFormat "--stream.sampleformat ${cfg.sampleFormat}"
  +    ++ optionalNull cfg.codec "--stream.codec ${cfg.codec}"
  +    ++ optionalNull cfg.streamBuffer "--stream.stream_buffer ${cfg.streamBuffer}"
  +    ++ optionalNull cfg.buffer "--stream.buffer ${cfg.buffer}"
  +    ++ optional cfg.sendToMuted "--stream.send_to_muted"
  +    # tcp json rpc
  +    ++ [ "--tcp.enabled ${toString cfg.tcp.enable}" ]
  +    ++ optionals cfg.tcp.enable [
  +      "--tcp.address ${cfg.tcp.listenAddress}"
  +      "--tcp.port ${toString cfg.tcp.port}" ]
  +     # http json rpc
  +    ++ [ "--http.enabled ${toString cfg.http.enable}" ]
  +    ++ optionals cfg.http.enable [
  +      "--http.address ${cfg.http.listenAddress}"
  +      "--http.port ${toString cfg.http.port}"
  +    ] ++ optional (cfg.http.docRoot != null) "--http.doc_root \"${toString cfg.http.docRoot}\"");
   
   in {
  +  imports = [
  +    (mkRenamedOptionModule [ "services" "snapserver" "controlPort"] [ "services" "snapserver" "tcp" "port" ])
  +  ];
   
     ###### interface
   
  
positive.code:       };
      };
  
      networking.firewall.allowedTCPPorts = optionals cfg.openFirewall [ cfg.port cfg.controlPort ];
    };
  
    meta = {
  
negative.code:         default = false;
          description = ''
            Whether to enable snapserver.
          '';
        };
  
        listenAddress = mkOption {
          type = types.str;
          default = "::";
          example = "0.0.0.0";
          description = ''
            The address where snapclients can connect.
          '';
        };
  
  