anchor.diff:          serviceConfig.PermissionsStartOnly = true;
         };
   
  -      dd-jmxfetch = lib.mkIf (cfg.jmxConfig != null) (makeService {
  +      dd-jmxfetch = lib.mkIf (lib.hasAttr "jmx" cfg.checks) (makeService {
           description = "Datadog JMX Fetcher";
           path = [ cfg.package pkgs.python pkgs.sysstat pkgs.procps pkgs.jdk ];
           serviceConfig.ExecStart = "${cfg.package}/bin/dd-jmxfetch";
  
positive.code:       '';
       };
  
      diskConfig = mkOption {
        description = "Disk check config";
        type = types.attrs;
        default = {
          init_config = {};
          instances = [ { use-mount = "no"; } ];
        };
       };
  
      networkConfig = mkOption {
        description = "Network check config";
        type = types.attrs;
        default = {
          init_config = {};
          # Network check only supports one configured instance
          instances = [ { collect_connection_state = false;
                          excluded_interfaces = [ "lo" "lo0" ]; } ];
        };
      };
  
      postgresqlConfig = mkOption {
        description = "Datadog PostgreSQL integration configuration";
        default = null;
        type = types.nullOr types.attrs;
      };
  
      nginxConfig = mkOption {
        description = "Datadog nginx integration configuration";
        default = null;
        type = types.nullOr types.attrs;
      };
  
      mongoConfig = mkOption {
        description = "MongoDB integration configuration";
        default = null;
        type = types.nullOr types.attrs;
      };
  
      jmxConfig = mkOption {
        description = "JMX integration configuration";
        default = null;
        type = types.nullOr types.attrs;
      };
  
      processConfig = mkOption {
        description = ''
          Process integration configuration
  
          See http://docs.datadoghq.com/integrations/process/
        '';
        default = null;
        type = types.nullOr types.attrs;
      };
  
    };
  
    config = mkIf cfg.enable {
      environment.systemPackages = [ cfg.package pkgs.sysstat pkgs.procps ];
  
  
negative.code:   // optionalAttrs (cfg.tags != null ) { tags = concatStringsSep ", " cfg.tags; }
    // cfg.extraConfig;
  
    # Generate Datadog configuration files for each configured checks.
    # This works because check configurations have predictable paths,
    # and because JSON is a valid subset of YAML.
    makeCheckConfigs = entries: mapAttrsToList (name: conf: {
      source = pkgs.writeText "${name}-check-conf.yaml" (builtins.toJSON conf);
      target = "datadog-agent/conf.d/${name}.d/conf.yaml";
    }) entries;
  
    defaultChecks = {
      disk = cfg.diskCheck;
      network = cfg.networkCheck;
    };
  
    # Assemble all check configurations and the top-level agent
    # configuration.
    etcfiles = with pkgs; with builtins; [{
      source = writeText "datadog.yaml" (toJSON ddConf);
      target = "datadog-agent/datadog.yaml";
    }] ++ makeCheckConfigs (cfg.checks // defaultChecks);
  
  in {
    options.services.datadog-agent = {
  