How do you deal with nextcloud being stateful?

As documented in the manual, nextcloud is stateful, i.e. if you put

services.nextcloud = {
    enable = true;
    hostName = "oldhn.com";
    settings = {
        overwritehost = "oldowh.com";
    };
    ...
}

in your configuration.nix file, run nixos-rebuild switch, change your configuration.nix to

services.nextcloud = {
    enable = true;
    hostName = "newhn.com";
    settings = {
    };
    ...
}

and run nixos-rebuild switch again, you will still find oldhn.com and oldowh.com in /var/lib/nextcloud/config/config.php and nextcloud will still use the old values.

I’m … not happy about that … to put it mildly. It makes services.nextcloud unusable to me.

To all those here who use services.nextcloud: How do you deal with this? Do you use the nextcloud-occ command to imperatively change the config? Do you nuke your nextcloud installation everytime you touch services.nextcloud in configuration.nix?

huh, I kinda expected nextcloud would still use oldowh.com but not oldhn.com (because newhn.com should override oldhn.com). So far my solution has been: once you set something in settings, keep setting it there (even if you want to go “back to the default”, explicitly configure that value). It’s odd that that doesn’t seem to be happening for you for oldhn.com - that might be worth diagnosing further.

That said, there’s also some things that can only be set ‘imperatively’ and not via settings at all. For those I indeed use nextcloud-occ, via the technique documented at Nextcloud - Official NixOS Wiki

1 Like

Weird, I can’t reproduce it anymore…
It seems like services.nextcloud.hostName is indeed stateless, just services.nextcloud.settings is not.
Maybe I looked at the wrong part of config.php.
Anyway, thank you for your input.