dotfiles/nixos/modules/services/nextcloud.nix

116 lines
2.7 KiB
Nix
Raw Normal View History

2024-10-06 15:25:05 -05:00
{
flake,
config,
pkgs,
...
}: let
inherit (flake.config.people) user0;
2024-10-18 12:37:23 -05:00
inherit (flake.config.people.user.${user0}) domain name;
2024-10-18 11:52:28 -05:00
inherit (flake.config.system.device) server wildcard;
2024-10-06 15:25:05 -05:00
inherit (flake.config.service.instance) nextcloud nginx;
localhost = wildcard.ip.address0;
2024-10-18 03:47:04 -05:00
host = "${nextcloud.subdomain}.${domain.url1}";
2024-10-06 15:25:05 -05:00
in {
services = {
nextcloud = {
appstoreEnable = true;
autoUpdateApps.enable = true;
configureRedis = true;
enable = true;
hostName = host;
https = true;
2024-10-18 12:03:00 -05:00
package = pkgs.nextcloud30;
2024-10-06 15:25:05 -05:00
phpOptions."opcache.interned_strings_buffer" = "24";
2024-10-18 12:29:30 -05:00
extraAppsEnable = true;
extraApps = {
inherit
(config.services.nextcloud.package.packages.apps)
2024-10-18 13:13:48 -05:00
calendar
2024-10-18 12:29:30 -05:00
;
};
2024-10-06 15:25:05 -05:00
config = {
2024-10-18 12:28:36 -05:00
adminpassFile = config.sops.secrets."${nextcloud.name}-pass".path;
2024-10-18 12:37:23 -05:00
adminuser = name;
2024-10-06 15:25:05 -05:00
dbtype = "pgsql";
};
database = {
createLocally = true;
};
settings = {
default_phone_region = "CA";
log_type = "file";
mail_sendmailmode = "pipe";
mail_smtpmode = "sendmail";
maintenance_window_start = 4;
overwriteprotocol = "https";
2024-10-18 02:04:02 -05:00
trusted_proxies = [
localhost
];
2024-10-06 15:25:05 -05:00
};
};
2024-10-18 01:52:47 -05:00
nginx = {
2024-10-18 01:50:18 -05:00
enable = true;
virtualHosts.${host}.listen = [
{
addr = wildcard.ip.address1;
port = nginx.ports.port0;
}
];
};
2024-10-06 15:25:05 -05:00
caddy = {
virtualHosts = {
2024-10-18 01:50:18 -05:00
"${host}" = {
2024-10-06 15:25:05 -05:00
extraConfig = ''
2024-10-18 01:50:18 -05:00
reverse_proxy ${localhost}:${toString nginx.ports.port0}
2024-10-06 15:25:05 -05:00
tls ${nextcloud.ssl.cert} ${nextcloud.ssl.key}
'';
};
};
};
};
sops = let
sopsSecrets = ["pass"];
sopsPath = secret: {
path = "${nextcloud.sops.path0}/${nextcloud.name}-${secret}";
owner = nextcloud.name;
mode = "600";
};
in {
secrets = builtins.listToAttrs (
map
(secret: {
name = "${nextcloud.name}-${secret}";
value = sopsPath secret;
})
sopsSecrets
);
};
2024-10-18 13:12:14 -05:00
fileSystems."/var/lib/${nextcloud.name}" = {
device = nextcloud.paths.path0;
fsType = "none";
2024-10-18 13:21:45 -05:00
options = ["bind" "rw"];
2024-10-18 13:12:14 -05:00
depends = [server.storage0.mount];
};
2024-10-06 15:25:05 -05:00
2024-10-18 13:12:14 -05:00
systemd.tmpfiles.rules = [
2024-10-18 13:19:59 -05:00
"Z ${nextcloud.paths.path0} 750 ${nextcloud.name} ${nextcloud.name} -"
"Z ${nextcloud.sops.path0} 750 ${nextcloud.name} ${nextcloud.name} -"
2024-10-18 13:12:14 -05:00
];
2024-10-06 15:25:05 -05:00
users.users.${nextcloud.name}.extraGroups = ["caddy" "nginx" "postgres"];
networking = {
firewall = {
allowedTCPPorts = [
nginx.ports.port0
nextcloud.ports.port0
];
};
};
}