anchor.diff:      "--pidfile /run/AdGuardHome/AdGuardHome.pid"
       "--work-dir /var/lib/AdGuardHome/"
       "--config /var/lib/AdGuardHome/AdGuardHome.yaml"
  -    "--host ${cfg.host}"
  -    "--port ${toString cfg.port}"
     ] ++ cfg.extraArgs);
   
  -in
  -{
  +  baseConfig = {
  +    bind_host = cfg.host;
  +    bind_port = cfg.port;
  +  };
  +
  +  configFile = pkgs.writeTextFile {
  +    name = "AdGuardHome.yaml";
  +    text = builtins.toJSON (recursiveUpdate cfg.settings baseConfig);
  +    checkPhase = "${pkgs.adguardhome}/bin/adguardhome -c $out --check-config";
  +  };
  +
  +in {
     options.services.adguardhome = with types; {
       enable = mkEnableOption "AdGuard Home network-wide ad blocker";
   
  
positive.code:       '';
      };
  
      extraArgs = mkOption {
        default = [ ];
        type = listOf str;
  
negative.code:         StartLimitIntervalSec = 5;
          StartLimitBurst = 10;
        };
  
        preStart = ''
          if    [ -e "$STATE_DIRECTORY/AdGuardHome.yaml" ] \
             && [ "${toString cfg.mutableSettings}" = "1" ]; then
            # Writing directly to AdGuardHome.yaml results in empty file
            ${pkgs.yaml-merge}/bin/yaml-merge "$STATE_DIRECTORY/AdGuardHome.yaml" "${configFile}" > "$STATE_DIRECTORY/AdGuardHome.yaml.tmp"
            mv "$STATE_DIRECTORY/AdGuardHome.yaml.tmp" "$STATE_DIRECTORY/AdGuardHome.yaml"
          else
            cp --force "${configFile}" "$STATE_DIRECTORY/AdGuardHome.yaml"
            chmod 600 "$STATE_DIRECTORY/AdGuardHome.yaml"
          fi
        '';
  
        serviceConfig = {
          DynamicUser = true;
          ExecStart = "${pkgs.adguardhome}/bin/adguardhome ${args}";
  