anchor.diff:        '';
       };
   
  +    mutableSettings = mkOption {
  +      default = true;
  +      type = bool;
  +      description = ''
  +        Allow changes made on the AdGuard Home web interface to persist between
  +        service restarts.
  +      '';
  +    };
  +
  +    settings = mkOption {
  +      type = (pkgs.formats.yaml { }).type;
  +      default = { };
  +      description = ''
  +        AdGuard Home configuration. Refer to
  +        <link xlink:href="https://github.com/AdguardTeam/AdGuardHome/wiki/Configuration#configuration-file"/>
  +        for details on supported values.
  +
  +        <note><para>
  +          On start and if <option>mutableSettings</option> is <literal>true</literal>,
  +          these options are merged into the configuration file on start, taking
  +          precedence over configuration changes made on the web interface.
  +        </para></note>
  +      '';
  +    };
  +
       extraArgs = mkOption {
         default = [ ];
         type = listOf str;
  
positive.code:         StartLimitIntervalSec = 5;
          StartLimitBurst = 10;
        };
        serviceConfig = {
          DynamicUser = true;
          ExecStart = "${pkgs.adguardhome}/bin/adguardhome ${args}";
  
negative.code:     "--pidfile /run/AdGuardHome/AdGuardHome.pid"
      "--work-dir /var/lib/AdGuardHome/"
      "--config /var/lib/AdGuardHome/AdGuardHome.yaml"
    ] ++ cfg.extraArgs);
  
    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";
  
  