2021-02-01 11:44:21 +01:00
|
|
|
# A self-hosted cloud.
|
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
let
|
|
|
|
cfg = config.my.services.nextcloud;
|
|
|
|
domain = config.networking.domain;
|
|
|
|
nextcloudDomain = "nextcloud.${config.networking.domain}";
|
|
|
|
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";
|
|
|
|
};
|
|
|
|
password = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
example = "password";
|
|
|
|
description = "The admin user's password";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
services.nextcloud = {
|
|
|
|
enable = true;
|
2021-03-20 01:25:18 +01:00
|
|
|
package = pkgs.nextcloud21;
|
2021-02-01 11:44:21 +01:00
|
|
|
hostName = nextcloudDomain;
|
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;
|
|
|
|
adminpass = cfg.password; # Insecure, but I don't care
|
|
|
|
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" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
services.nginx.virtualHosts."${nextcloudDomain}" = {
|
|
|
|
forceSSL = true;
|
2021-02-24 21:50:05 +01:00
|
|
|
useACMEHost = domain;
|
2021-02-01 11:44:21 +01:00
|
|
|
|
|
|
|
locations."/".proxyPass = "http://localhost:3000/";
|
|
|
|
};
|
2021-02-07 20:33:36 +01:00
|
|
|
|
|
|
|
my.services.backup = {
|
|
|
|
paths = [
|
|
|
|
config.services.nextcloud.home
|
|
|
|
];
|
|
|
|
};
|
2021-02-01 11:44:21 +01:00
|
|
|
};
|
|
|
|
}
|