2021-03-23 19:31:59 +01:00
|
|
|
{ lib, config, pkgs, ... }:
|
|
|
|
|
|
|
|
# TODO: setup prometheus exporter
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.my.services.nextcloud;
|
|
|
|
my = config.my;
|
|
|
|
domain = config.networking.domain;
|
|
|
|
dbName = "nextcloud";
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options.my.services.nextcloud = {
|
|
|
|
enable = lib.mkEnableOption "NextCloud";
|
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
services.postgresql = {
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
ensureDatabases = [ dbName ];
|
|
|
|
ensureUsers = [
|
|
|
|
{
|
|
|
|
name = "nextcloud";
|
|
|
|
ensurePermissions = {
|
|
|
|
"DATABASE ${dbName}" = "ALL PRIVILEGES";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2021-03-24 00:14:43 +01:00
|
|
|
# not handled by module
|
|
|
|
systemd.services.nextcloud-setup= {
|
|
|
|
requires = [ "postgresql.service" ];
|
|
|
|
after = [ "postgresql.service" ];
|
|
|
|
};
|
|
|
|
|
2021-03-23 19:31:59 +01:00
|
|
|
services.postgresqlBackup = {
|
|
|
|
databases = [ dbName ];
|
|
|
|
};
|
|
|
|
|
|
|
|
services.nextcloud = {
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
hostName = "cloud.${domain}";
|
|
|
|
https = true;
|
2021-08-20 01:52:45 +02:00
|
|
|
package = pkgs.nextcloud22;
|
2021-03-23 19:31:59 +01:00
|
|
|
|
|
|
|
maxUploadSize = "1G";
|
|
|
|
|
|
|
|
config = {
|
|
|
|
overwriteProtocol = "https";
|
|
|
|
|
|
|
|
defaultPhoneRegion = "FR";
|
|
|
|
|
|
|
|
dbtype = "pgsql";
|
|
|
|
dbuser = "nextcloud";
|
|
|
|
dbname = dbName;
|
|
|
|
dbhost = "/run/postgresql";
|
|
|
|
|
|
|
|
adminuser = my.secrets.nextcloud-admin-user;
|
2021-11-17 00:58:54 +01:00
|
|
|
adminpassFile = "${my.secrets.nextcloud-admin-pass}";
|
2021-03-23 19:31:59 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
services.nginx = {
|
|
|
|
virtualHosts = {
|
|
|
|
"cloud.${domain}" = {
|
|
|
|
forceSSL = true;
|
2021-07-13 00:57:33 +02:00
|
|
|
useACMEHost = domain;
|
2021-03-23 19:31:59 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-08-09 20:19:27 +02:00
|
|
|
my.services.restic-backup = let
|
2021-03-24 00:31:45 +01:00
|
|
|
nextcloudHome = config.services.nextcloud.home;
|
|
|
|
in lib.mkIf cfg.enable {
|
|
|
|
paths = [ nextcloudHome ];
|
2021-03-24 19:37:00 +01:00
|
|
|
exclude = [
|
|
|
|
# borg can fail if *.part files disappear during backup
|
2021-08-09 21:09:32 +02:00
|
|
|
"${nextcloudHome}/data/*/uploads"
|
2021-03-24 19:37:00 +01:00
|
|
|
# image previews can take up a lot of space
|
2021-08-09 21:09:32 +02:00
|
|
|
"${nextcloudHome}/data/appdata_*/preview"
|
2021-08-10 00:33:19 +02:00
|
|
|
# specific account for huge files I don't care about losing
|
|
|
|
"${nextcloudHome}/data/misc"
|
2021-03-24 19:37:00 +01:00
|
|
|
];
|
2021-03-23 19:31:59 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|