Nextcloud not working, but no warnings

I am currently trying to set up a Nextcloud server on NixOS because it seemed like it’d be easier than on other distros (finally an easy-to-use firewall and so on), and I’m rather new to both. When I rebuild the configuration (nixos-rebuild switch), it doesn’t return any errors or warnings. However when I try to connect to the localhost or the local IP address on the server it runs on, Firefox always says it was “unable to connect” (however it always switches to /login (e.g. localhost/nextcloud will bring me to https://localhost/login), so some part of the webserver must be running). I mostly followed the manual’s instructions for enabling Nextcloud and so. I even tried reinstalling NixOS to see whether it’d change anything. I guess these are the relevant parts in my configuration:

networking.hostName = “FuerstServer”; # Define your hostname.
#Nextcloud config
services.nextcloud = {
enable = true;
autoUpdateApps.enable = true;
hostName = “fuerstserver.org”;
nginx.enable = true;
config = {
dbtype = “pgsql”;
dbuser = “nextcloud”;
dbhost = “/run/postgresql”; # nextcloud will add /.s.PGSQL.5432 by itself
#adminpassFile = “/var/lib/nextcloud/config/passwd”;
adminpass = “my password, won’t type that here”; #just for testing, will change to file later
adminuser = “root”;
extraTrustedDomains = [ “192.168.1.162” “fuerstserver.fritz.box” ];
overwriteProtocol = “https”;
};
};

services.postgresql = {
enable = true;
ensureDatabases = [ “nextcloud” ];
ensureUsers = [
{ name = “nextcloud”;
ensurePermissions.“DATABASE nextcloud” = “ALL PRIVILEGES”;
}
];
};

#ensure that postgres is running before running the setup
systemd.services.“nextcloud-setup” = {
requires = [“postgresql.service”];
after = [“postgresql.service”];
};

#Enable the OpenSSH daemon.
services.openssh.enable = true;

#Open ports in the firewall.
networking.firewall.allowedTCPPorts = [ 22 80 443 ];
#networking.firewall.allowedUDPPorts = [ … ];
networking.firewall.enable = true;

Hi,

I have very similar config, the only differences are that I run it in the container and I’ve changed:

services.config.adminuser = "admin";
services.nextcloud.home = "/tank/nextcloud"; 

I guess we both followed nixOS manual.

Unfortunately when I go to http://my-domain I get:

Error

It looks like you are trying to reinstall your Nextcloud. However the file CAN_INSTALL is missing from your config directory. Please create the file CAN_INSTALL in your config folder to continue.

I can’t see any logs, nothing in /var/log nor in journalctl or
/nix/store/692666sls0cxiw5dfpn3kadwxhaydb6r-nextcloud-16.0.5 Where it seems o be installed.
I’ve noticed that there is no config.php in that directory (is this expected?) and touching CAN_INSTALL change nothing.

Any ideas?

See my config:

 containers.nextcloud = {
   privateNetwork  = true;
   hostBridge      = "br0";
   localAddress    = "10.1.0.14/24";
   autoStart       = true;
   timeoutStartSec = "5min";
   bindMounts = {
     "/data" = { hostPath = "/data/nextcloud/data"; isReadOnly = false; 
     "/db" = { hostPath = "/data/nextcloud/db"; isReadOnly = false; };
   };
   config = { config, pkgs, ... }: {
     networking.interfaces.eth0.ipv4.routes = [
       { address = "0.0.0.0"; prefixLength = 0; via = "10.1.0.1"; }
     ];
     networking.firewall.enable = false;
     environment.systemPackages = with pkgs; [
       vim
       fswatch
       ffmpeg
     ];
     services.nginx.enable = true;
     services.postgresql = {
       enable         = true;
       package        = pkgs.postgresql_10;
       dataDir        = "/db";
       enableTCPIP    = true;
       authentication = pkgs.lib.mkOverride 10 ''
       local all all trust
       host all all ::1/128 trust
       '';
       initialScript = pkgs.writeText "backend-initScript" ''
       CREATE ROLE nextcloud WITH LOGIN PASSWORD 'DB-PASS' CREATEDB;
       CREATE DATABASE nextcloud;
       GRANT ALL PRIVILEGES ON DATABASE nextcloud TO nextcloud;
       '';
     };
     services.nextcloud = {
       enable       = true;
       hostName     = "cloud.foo.org";
       home         = "/data";
       nginx.enable = true;
       config = {
         dbtype              = "pgsql";
         dbuser              = "nextcloud";
         dbpass              = "DB-PASS";
         dbname              = "nextcloud";
         adminuser           = "USER";
         adminpass           = "PASS";
         extraTrustedDomains = [ "10.1.0.14" "cloud.foo.org" ];
       };
     };
   };
 };

I weren’t setting up from scratch for a long time, but AFAIR as a result it produced provisioned, ready to be used instance.

Thanks @otwieracz.
Firstly - I didn’t remove the container correctly. It seems like deleting its configuration from the configuration.nix is not enough you need to remove /var/lib/containers/{name} Which caused my issue.
Secondly - I missed bindMount when trying to change services.nextcloud.home.

@FantasyCookie17 how about trying nextcloud in nixos container? So you can be sure to have clean environment?