nixos/services/nextcloud.nix
derped 92cd95d6ce
mysql: Use ensure* options, split definition up into service files.
note/reason for split: nixos submodule option names aren't standardized...
2019-12-20 08:48:37 +01:00

63 lines
1.6 KiB
Nix

{ config, lib, ... }:
with lib;
mkIf (elem "nextcloud" config.machine.services) {
services = let
cfg = config.machine;
domain = (findFirst (s: s.service == "nextcloud") cfg cfg.vHosts).domain;
in {
nextcloud = {
enable = true;
home = "/var/lib/nextcloud";
hostName = domain;
https = true;
maxUploadSize = "1024M";
config = {
adminuser = mkDefault (elemAt cfg.administrators 0).name;
adminpassFile = "${cfg.secretPath}/nextcloud_admin";
dbtype = "mysql";
dbhost = "localhost";
dbport = "3306";
dbuser = "nextcloud";
dbpassFile = "${cfg.secretPath}/nextcloud_db";
dbname = "nextcloud";
dbtableprefix = "oc_";
extraTrustedDomains = cfg.extraDomains;
};
caching = {
apcu = true;
memcached = true;
redis = false;
};
};
# Turn Server used for nextcloud-talk
# This stuff is still untested.
coturn = mkIf (elem "nextcloud-talk" config.machine.services) {
# TLS is not needed as WebRTC is already encrypted.
enable = true;
realm = domain;
listening-port = 3478;
use-auth-secret = true;
extraConfig = ''
fingerprint
total-quota=100
bps-capacity=0
stale-nonce
no-multicast-peers
'';
};
mysql = let
cfg = config.services.nextcloud.config;
in {
ensureDatabases = [ cfg.dbname ];
ensureUsers = [{
name = cfg.dbuser;
ensurePermissions = {
"${cfg.dbname}.*" = "ALL PRIVILEGES";
};
}];
};
};
}