How to add custom options to the deeply-nested Nextcloud configuration file

I’m trying to set up a Nextcloud service, and one of the things I need to do is configure it to use object storage instead of the filesystem. Unfortunately, there is no sort of extraConfig option (yet) for Nextcloud.

Essentially what I need to do is modify the nextcloud-config.php file that the service definition writes out. And that’s what I don’t know how to do. I don’t think it’s as simple as appending the php config with a lib.mkAfter, because the file contents are declared in a let block. And I don’t see anything that can be cleanly overridden, without copy-pasting large parts of the service definition referenced by this script.

What’s the best way to go here?

(disclaimer: I know nothing about PHP or Nextcloud) Looking at the code, I agree that there is no nice way to do this. The best solution I can come up with is to use
services.nextcloud.config.defaultPhoneRegion to inject arbitrary php code, since it just takes a string and it’s inserted, unescaped, into the file.

2 Likes

Ooh, now that’s a clever hack! It may be just what I need for the moment, until the extraOptions PR gets through.

Thanks!

Do you think your finding is worth opening a ticket ?

I think this sort of thing is all over the nixos module code tbh, and I would assume the aforementioned extraOptions PR would just be allowing you to add whatever PHP code you want, so I don’t think this hack is of any concern. That being said I am not a security expert.