2021-02-01 11:44:21 +01:00
|
|
|
# A self-hosted cloud.
|
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
let
|
|
|
|
cfg = config.my.services.nextcloud;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options.my.services.nextcloud = with lib; {
|
|
|
|
enable = mkEnableOption "Nextcloud";
|
|
|
|
maxSize = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "512M";
|
|
|
|
example = "1G";
|
|
|
|
description = "Maximum file upload size";
|
|
|
|
};
|
|
|
|
admin = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "Ambroisie";
|
|
|
|
example = "admin";
|
|
|
|
description = "Name of the admin user";
|
|
|
|
};
|
2021-09-25 13:02:13 +02:00
|
|
|
passwordFile = mkOption {
|
2021-02-01 11:44:21 +01:00
|
|
|
type = types.str;
|
2021-09-25 13:02:13 +02:00
|
|
|
example = "/var/lib/nextcloud/password.txt";
|
|
|
|
description = ''
|
|
|
|
Path to a file containing the admin's password, must be readable by
|
|
|
|
'nextcloud' user.
|
|
|
|
'';
|
2021-02-01 11:44:21 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
services.nextcloud = {
|
|
|
|
enable = true;
|
2022-10-26 14:15:34 +02:00
|
|
|
package = pkgs.nextcloud25;
|
2021-08-24 23:05:10 +02:00
|
|
|
hostName = "nextcloud.${config.networking.domain}";
|
2021-02-07 21:00:20 +01:00
|
|
|
home = "/var/lib/nextcloud";
|
2021-02-01 11:44:21 +01:00
|
|
|
maxUploadSize = cfg.maxSize;
|
|
|
|
config = {
|
|
|
|
adminuser = cfg.admin;
|
2021-09-25 13:02:13 +02:00
|
|
|
adminpassFile = cfg.passwordFile;
|
2021-02-01 11:44:21 +01:00
|
|
|
dbtype = "pgsql";
|
|
|
|
dbhost = "/run/postgresql";
|
|
|
|
overwriteProtocol = "https"; # Nginx only allows SSL
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
services.postgresql = {
|
|
|
|
enable = true;
|
|
|
|
ensureDatabases = [ "nextcloud" ];
|
|
|
|
ensureUsers = [
|
|
|
|
{
|
|
|
|
name = "nextcloud";
|
|
|
|
ensurePermissions."DATABASE nextcloud" = "ALL PRIVILEGES";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services."nextcloud-setup" = {
|
|
|
|
requires = [ "postgresql.service" ];
|
|
|
|
after = [ "postgresql.service" ];
|
|
|
|
};
|
|
|
|
|
2021-08-24 23:05:10 +02:00
|
|
|
# The service above configures the domain, no need for my wrapper
|
|
|
|
services.nginx.virtualHosts."nextcloud.${config.networking.domain}" = {
|
2021-02-01 11:44:21 +01:00
|
|
|
forceSSL = true;
|
2021-08-24 23:05:10 +02:00
|
|
|
useACMEHost = config.networking.domain;
|
2021-02-01 11:44:21 +01:00
|
|
|
};
|
2021-02-07 20:33:36 +01:00
|
|
|
|
|
|
|
my.services.backup = {
|
|
|
|
paths = [
|
|
|
|
config.services.nextcloud.home
|
|
|
|
];
|
2021-08-19 14:27:06 +02:00
|
|
|
exclude = [
|
|
|
|
# image previews can take up a lot of space
|
|
|
|
"${config.services.nextcloud.home}/data/appdata_*/preview"
|
|
|
|
];
|
2021-02-07 20:33:36 +01:00
|
|
|
};
|
2021-02-01 11:44:21 +01:00
|
|
|
};
|
|
|
|
}
|