2024-10-06 15:25:05 -05:00
|
|
|
{
|
|
|
|
flake,
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
...
|
2025-02-05 20:15:36 -06:00
|
|
|
}:
|
|
|
|
let
|
|
|
|
inherit (flake.config.people)
|
2025-01-08 19:06:14 -06:00
|
|
|
user0
|
|
|
|
;
|
2025-02-05 20:15:36 -06:00
|
|
|
inherit (flake.config.people.users.${user0})
|
2025-01-08 19:06:14 -06:00
|
|
|
name
|
|
|
|
;
|
2025-02-05 20:15:36 -06:00
|
|
|
inherit (flake.config.machines.devices)
|
2025-02-17 18:52:02 -06:00
|
|
|
ceres
|
2025-01-08 19:06:14 -06:00
|
|
|
;
|
2025-02-05 20:15:36 -06:00
|
|
|
inherit (flake.config.services.instances)
|
2025-01-08 19:06:14 -06:00
|
|
|
nextcloud
|
|
|
|
nginx
|
|
|
|
web
|
|
|
|
;
|
2024-10-19 18:22:29 -05:00
|
|
|
service = nextcloud;
|
|
|
|
localhost = web.localhost.address0;
|
|
|
|
host = "${service.subdomain}.${web.domains.url1}";
|
2025-02-05 20:15:36 -06:00
|
|
|
in
|
|
|
|
{
|
2024-10-06 15:25:05 -05:00
|
|
|
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 13:31:22 -05:00
|
|
|
extraAppsEnable = true;
|
|
|
|
extraApps = {
|
2025-02-05 20:15:36 -06:00
|
|
|
inherit (config.services.service.package.packages.apps)
|
2024-10-18 13:57:54 -05:00
|
|
|
contacts
|
2024-10-18 13:31:22 -05:00
|
|
|
calendar
|
|
|
|
;
|
|
|
|
};
|
2024-10-06 15:25:05 -05:00
|
|
|
config = {
|
2024-10-19 18:22:29 -05:00
|
|
|
adminpassFile = config.sops.secrets."${service.name}-pass".path;
|
2024-10-18 13:31:22 -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 = [
|
|
|
|
{
|
2024-10-19 18:22:29 -05:00
|
|
|
addr = web.localhost.address1;
|
2024-10-18 01:50:18 -05:00
|
|
|
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-19 18:22:29 -05:00
|
|
|
tls ${service.ssl.cert} ${service.ssl.key}
|
2024-10-06 15:25:05 -05:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2025-02-05 20:15:36 -06:00
|
|
|
sops =
|
|
|
|
let
|
|
|
|
sopsPath = secret: {
|
|
|
|
path = "${service.sops.path0}/${service.name}-${secret}";
|
|
|
|
owner = service.name;
|
|
|
|
mode = "600";
|
|
|
|
};
|
|
|
|
in
|
|
|
|
{
|
|
|
|
secrets = builtins.listToAttrs (
|
|
|
|
map
|
|
|
|
(secret: {
|
|
|
|
name = "${service.name}-${secret}";
|
|
|
|
value = sopsPath secret;
|
|
|
|
})
|
|
|
|
[
|
|
|
|
"pass"
|
|
|
|
]
|
|
|
|
);
|
2024-10-06 15:25:05 -05:00
|
|
|
};
|
|
|
|
|
2024-10-19 18:22:29 -05:00
|
|
|
fileSystems."/var/lib/${service.name}" = {
|
|
|
|
device = service.paths.path0;
|
|
|
|
fsType = "none";
|
2025-01-08 19:06:14 -06:00
|
|
|
options = [
|
|
|
|
"bind"
|
|
|
|
];
|
2025-01-08 19:11:58 -06:00
|
|
|
depends = [
|
2025-02-17 18:52:02 -06:00
|
|
|
ceres.storage0.mount
|
2025-01-08 19:11:58 -06:00
|
|
|
];
|
2024-10-19 18:22:29 -05:00
|
|
|
};
|
2024-10-06 15:25:05 -05:00
|
|
|
|
2024-10-19 18:22:29 -05:00
|
|
|
systemd.tmpfiles.rules = [
|
|
|
|
"Z ${service.paths.path0} 750 ${service.name} ${service.name} -"
|
|
|
|
"Z ${service.sops.path0} 750 ${service.name} ${service.name} -"
|
|
|
|
];
|
2024-10-06 15:25:05 -05:00
|
|
|
|
2025-01-08 19:06:14 -06:00
|
|
|
users.users.${service.name}.extraGroups = [
|
|
|
|
"caddy"
|
|
|
|
"nginx"
|
|
|
|
"postgres"
|
|
|
|
];
|
2024-10-06 15:25:05 -05:00
|
|
|
|
|
|
|
networking = {
|
|
|
|
firewall = {
|
|
|
|
allowedTCPPorts = [
|
|
|
|
nginx.ports.port0
|
2024-10-19 18:22:29 -05:00
|
|
|
service.ports.port0
|
2024-10-06 15:25:05 -05:00
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|