anchor.diff:            };
           '';
         };
  -
  -      streamBuffer = mkOption {
  -        type = with types; nullOr int;
  -        default = null;
  -        description = ''
  -          Stream read (input) buffer in ms.
  -        '';
  -        example = 20;
  -      };
  -
  -      buffer = mkOption {
  -        type = with types; nullOr int;
  -        default = null;
  -        description = ''
  -          Network buffer in ms.
  -        '';
  -        example = 1000;
  -      };
  -
  -      sendToMuted = mkOption {
  -        type = types.bool;
  -        default = false;
  -        description = ''
  -          Send audio to muted clients.
  -        '';
  -      };
       };
  -
     };
   
   
  
positive.code:         default = false;
          description = ''
            Whether to enable snapserver.
          '';
        };
  
  
negative.code:     let
        os = val:
          optionalString (val != null) "${val}";
        os' = prefix: val:
          optionalString (val != null) (prefix + "${val}");
        flatten = key: value:
          "&${key}=${value}";
      in
        "--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
      # 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
  
  