Nextcloud: Configuration was not read or initialized correctly (mounted datadir drive)

I currently have the following nextcloud configuration:

 services.nextcloud = {
      enable = true;
      configureRedis = true;
      package = pkgs.nextcloud30;
      hostName = "server.nextcloud.home";
      datadir = "/mnt/storage/nextcloud";
      database.createLocally = true;
      extraAppsEnable = true;
      autoUpdateApps.enable = true;

      config = {
        dbtype = "pgsql";
        adminpassFile = config.sops.secrets.nextcloud-admin.path;
        adminuser = "admin";
      };
    };

    services.nginx.virtualHosts${config.services.nextcloud.hostName}.listen = [
      {
        addr = "0.0.0.0";
        port = 8081;
      }
    ];

The first issue I have is having home on an external drive. This results in

Configuration was not read or initialized correctly, not overwriting /mnt/storage/nextcloud/config/config.php

When disabling this line for testing purposes, I still encounter the problem that my connection via a tailscale network is not a trusted domain. Adding every device via settings.trustedDomains seems not the correct solution to me.

Are there any solutions for my two problems?

How about this for the trusted domains issue? (Use wildcard for subnet values)

1 Like

Thanks. This could solve my problem. Sadly I am not even to getting to this error message anymore, as now every set home or datadir results in

Configuration was not read or initialized correctly, not overwriting config/config.php

with the config directory just being empty without any files and the whole folder being owned by the root user

For troubleshooting, maybe remove the datadir setting and just go with the default/var/lib/nextcloud until you get the rest of it working.

Thanks, this works now without any issues, after I deleted all the files and databases manually

Now the only issue is with the non-default datadir, which also has no config.php file in it