anchor.diff:      ''}
       ${cfg.appendConfig}
     '';
  +  configFile = pkgs.runCommand "nginx.conf" {
  +    text = configFileText;
  +    passAsFile = ["text"];
  +    preferLocalBuild = true;
  +    allowSubstitutes = false;
  +  } ''
  +    mkdir -p "$(dirname "$out")"
  +    mv "$textPath" "$out"
  +    (${nginx}/bin/nginx -t -c "$out" -p ${cfg.stateDir} || true) 2>&1 | grep -q 'syntax is ok'
  +  '';
  +
   in
   
   {
  
positive.code: let
    cfg = config.services.nginx;
    nginx = cfg.package;
    configFile = pkgs.writeText "nginx.conf" ''
      user ${cfg.user} ${cfg.group};
      daemon off;
  
  
negative.code:   };
  
    config = mkIf cfg.enable {
      systemd.services.nginx = {
        description = "Nginx Web Server";
        after = [ "network.target" ];
  