anchor.diff:      };
     };
   
  -  prometheusYml = let
  -    yml = if cfg.configText != null then
  -      pkgs.writeText "prometheus.yml" cfg.configText
  -      else generatedPrometheusYml;
  -    in promtoolCheck "check config" "prometheus.yml" yml;
  +  prometheusYml =
  +    let
  +      yml =
  +        if cfg.configText != null then
  +          pkgs.writeText "prometheus.yml" cfg.configText
  +        else generatedPrometheusYml;
  +    in
  +    promtoolCheck "check config" "prometheus.yml" yml;
   
     cmdlineArgs = cfg.extraFlags ++ [
       "--storage.tsdb.path=${workingDir}/data/"
  
positive.code:       wantedBy = [ "multi-user.target" ];
        after    = [ "network.target" ];
        preStart = mkIf (!cfg.enableReload) ''
           ${lib.getBin pkgs.envsubst}/bin/envsubst -o "/run/prometheus/prometheus-substituted.yaml" \
                                                    -i "${prometheusYml}"
        '';
        serviceConfig = {
          ExecStart = "${cfg.package}/bin/prometheus" +
  
negative.code:     "--alertmanager.notification-queue-capacity=${toString cfg.alertmanagerNotificationQueueCapacity}"
      "--alertmanager.timeout=${toString cfg.alertmanagerTimeout}s"
    ] ++ optional (cfg.webExternalUrl != null) "--web.external-url=${cfg.webExternalUrl}"
      ++ optional (cfg.retentionTime != null) "--storage.tsdb.retention.time=${cfg.retentionTime}";
  
    filterValidPrometheus = filterAttrsListRecursive (n: v: !(n == "_module" || v == null));
    filterAttrsListRecursive = pred: x:
      if isAttrs x then
        listToAttrs
          (
            concatMap
              (name:
                let v = x.${name}; in
                if pred name v then [
                  (nameValuePair name (filterAttrsListRecursive pred v))
                ] else [ ]
              )
              (attrNames x)
          )
      else if isList x then
        map (filterAttrsListRecursive pred) x
      else x;
  
    #
    # Config types: helper functions
    #
  
    mkDefOpt = type: defaultStr: description: mkOpt type (description + ''
  
      Defaults to <literal>${defaultStr}</literal> in prometheus
      when set to <literal>null</literal>.
    '');
  
    mkOpt = type: description: mkOption {
      type = types.nullOr type;
      default = null;
      inherit description;
    };
  
    mkSdConfigModule = extraOptions: types.submodule {
      options = {
        basic_auth = mkOpt promTypes.basic_auth ''
          Optional HTTP basic authentication information.
        '';
  
        authorization = mkOpt
          (types.submodule {
            options = {
              type = mkDefOpt types.str "Bearer" ''
                Sets the authentication type.
              '';
  
              credentials = mkOpt types.str ''
                Sets the credentials. It is mutually exclusive with `credentials_file`.
              '';
  
              credentials_file = mkOpt types.str ''
                Sets the credentials to the credentials read from the configured file.
                It is mutually exclusive with `credentials`.
              '';
            };
          }) ''
          Optional `Authorization` header configuration.
        '';
  
        oauth2 = mkOpt promtypes.oauth2 ''
          Optional OAuth 2.0 configuration.
          Cannot be used at the same time as basic_auth or authorization.
        '';
  
        proxy_url = mkOpt types.str ''
          Optional proxy URL.
        '';
  
        follow_redirects = mkDefOpt types.bool "true" ''
          Configure whether HTTP requests follow HTTP 3xx redirects.
        '';
  
        tls_config = mkOpt promTypes.tls_config ''
          TLS configuration.
        '';
      } // extraOptions;
    };
  
    #
    # Config types: general
    #
  
    promTypes.globalConfig = types.submodule {
      options = {
  