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;
|
2024-05-04 22:51:11 +02:00
|
|
|
package = pkgs.nextcloud29;
|
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;
|
2023-07-15 15:01:14 +02:00
|
|
|
configureRedis = true;
|
2021-02-01 11:44:21 +01:00
|
|
|
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";
|
2024-01-03 23:36:59 +01:00
|
|
|
};
|
|
|
|
|
2024-01-26 23:35:06 +01:00
|
|
|
https = true;
|
|
|
|
|
2024-01-30 13:21:50 +01:00
|
|
|
settings = {
|
2024-01-15 17:50:38 +01:00
|
|
|
overwriteprotocol = "https"; # Nginx only allows SSL
|
2021-02-01 11:44:21 +01:00
|
|
|
};
|
2023-07-15 15:45:42 +02:00
|
|
|
|
|
|
|
notify_push = {
|
|
|
|
enable = true;
|
|
|
|
# Allow using the push service without hard-coding my IP in the configuration
|
|
|
|
bendDomainToLocalhost = true;
|
|
|
|
};
|
2021-02-01 11:44:21 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
services.postgresql = {
|
|
|
|
enable = true;
|
|
|
|
ensureDatabases = [ "nextcloud" ];
|
|
|
|
ensureUsers = [
|
|
|
|
{
|
|
|
|
name = "nextcloud";
|
2023-11-21 00:18:29 +01:00
|
|
|
ensureDBOwnership = true;
|
2021-02-01 11:44:21 +01:00
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
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-11-05 15:11:35 +01:00
|
|
|
|
|
|
|
my.system.persist.directories = [
|
|
|
|
config.services.nextcloud.home
|
|
|
|
config.services.nextcloud.datadir
|
|
|
|
];
|
2021-02-01 11:44:21 +01:00
|
|
|
};
|
|
|
|
}
|