mirror of
https://gitlab.com/upRootNutrition/dotfiles.git
synced 2025-06-15 09:35:12 -05:00
146 lines
3.2 KiB
Nix
Executable file
146 lines
3.2 KiB
Nix
Executable file
{
|
|
flake,
|
|
config,
|
|
pkgs,
|
|
...
|
|
}:
|
|
let
|
|
inherit (flake.config.people) user0;
|
|
inherit (flake.config.people.users.${user0}) name;
|
|
inherit (flake.config.machines.devices) ceres;
|
|
inherit (flake.config.services.instances)
|
|
nextcloud
|
|
nginx
|
|
smtp
|
|
web
|
|
;
|
|
service = nextcloud;
|
|
localhost = web.localhost.address0;
|
|
host = "${service.subdomain}.${web.domains.url0}";
|
|
in
|
|
{
|
|
services = {
|
|
nextcloud = {
|
|
appstoreEnable = true;
|
|
autoUpdateApps.enable = true;
|
|
configureRedis = true;
|
|
enable = true;
|
|
hostName = host;
|
|
https = true;
|
|
package = pkgs.nextcloud31;
|
|
phpOptions."opcache.interned_strings_buffer" = "24";
|
|
extraAppsEnable = true;
|
|
extraApps = {
|
|
inherit (pkgs.nextcloud31Packages.apps)
|
|
contacts
|
|
calendar
|
|
deck
|
|
;
|
|
};
|
|
config = {
|
|
adminpassFile = config.sops.secrets."${service.name}-pass".path;
|
|
adminuser = name;
|
|
dbtype = "pgsql";
|
|
};
|
|
database = {
|
|
createLocally = true;
|
|
};
|
|
settings = {
|
|
default_phone_region = "CA";
|
|
log_type = "file";
|
|
mail_domain = host;
|
|
mail_from_address = "noreply";
|
|
mail_sendmailmode = "smtp";
|
|
mail_smtpmode = "smtp";
|
|
mail_smtphost = smtp.hostname;
|
|
mail_smtpport = smtp.ports.port0;
|
|
mail_smtpsecure = "ssl";
|
|
mail_smtptimeout = 30;
|
|
mail_smtpauth = 1;
|
|
mail_smtpname = service.email.address0;
|
|
mail_smtppassword = config.sops.secrets."${service.name}-smtp".path;
|
|
maintenance_window_start = 4;
|
|
overwriteprotocol = "https";
|
|
trusted_proxies = [
|
|
localhost
|
|
];
|
|
};
|
|
};
|
|
|
|
nginx = {
|
|
enable = true;
|
|
virtualHosts.${host}.listen = [
|
|
{
|
|
addr = web.localhost.address1;
|
|
port = nginx.ports.port0;
|
|
}
|
|
];
|
|
};
|
|
|
|
caddy = {
|
|
virtualHosts = {
|
|
"${host}" = {
|
|
extraConfig = ''
|
|
reverse_proxy ${localhost}:${toString nginx.ports.port0}
|
|
|
|
tls ${service.ssl.cert} ${service.ssl.key}
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
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"
|
|
"smtp"
|
|
]
|
|
);
|
|
};
|
|
|
|
fileSystems."/var/lib/${service.name}" = {
|
|
device = service.paths.path0;
|
|
fsType = "none";
|
|
options = [
|
|
"bind"
|
|
];
|
|
depends = [
|
|
ceres.storage0.mount
|
|
];
|
|
};
|
|
|
|
systemd.tmpfiles.rules = [
|
|
"Z ${service.paths.path0} 750 ${service.name} ${service.name} -"
|
|
"Z ${service.paths.path0}/config 750 ${service.name} ${service.name} -"
|
|
"Z ${service.sops.path0} 750 ${service.name} ${service.name} -"
|
|
];
|
|
|
|
users.users.${service.name}.extraGroups = [
|
|
"caddy"
|
|
"nginx"
|
|
"postgres"
|
|
];
|
|
|
|
networking = {
|
|
firewall = {
|
|
allowedTCPPorts = [
|
|
nginx.ports.port0
|
|
service.ports.port0
|
|
];
|
|
};
|
|
};
|
|
}
|