nix-config/config/services/nextcloud.nix

135 lines
3.5 KiB
Nix
Raw Normal View History

2023-12-03 15:15:42 +01:00
{
lib,
pkgs,
config,
2024-02-11 00:40:30 +01:00
nodes,
2024-12-20 20:40:27 +01:00
globals,
2023-12-03 15:15:42 +01:00
...
2024-07-26 22:12:48 +02:00
}:
{
2024-12-07 15:06:07 +01:00
age.secrets.mailnix-passwd = {
2024-02-11 00:40:30 +01:00
generator.script = "alnum";
2024-12-07 15:06:07 +01:00
group = "nextcloud";
2024-12-08 13:48:30 +01:00
mode = "440";
2024-02-11 00:40:30 +01:00
};
2024-12-07 15:06:07 +01:00
age.secrets.mailnix-passwd-hash = {
generator.dependencies = [ config.age.secrets.mailnix-passwd ];
generator.script = "argon2id";
mode = "440";
intermediary = true;
};
nodes.mailnix = {
age.secrets.idmail-nextcloud-passwd-hash = {
inherit (config.age.secrets.mailnix-passwd-hash) rekeyFile;
group = "stalwart-mail";
mode = "440";
2024-02-11 00:40:30 +01:00
};
2024-12-20 20:40:27 +01:00
services.idmail.provision.mailboxes."nextcloud@${globals.domains.mail_public}" = {
2024-12-07 15:06:07 +01:00
password_hash = "%{file:${nodes.mailnix.config.age.secrets.idmail-nextcloud-passwd-hash.path}}%";
owner = "admin";
2024-02-11 00:40:30 +01:00
};
};
environment.persistence."/persist".directories = [
{
directory = "/var/lib/postgresql/";
user = "postgres";
group = "postgres";
mode = "750";
}
];
environment.persistence."/panzer".directories = [
{
directory = config.services.nextcloud.home;
user = "nextcloud";
group = "nextcloud";
mode = "750";
}
];
age.secrets.ncpasswd = {
generator.script = "alnum";
mode = "440";
owner = "nextcloud";
};
services.postgresql.package = pkgs.postgresql_16;
services.nextcloud = {
2024-12-20 20:40:27 +01:00
hostName = globals.services.nextcloud.domain;
enable = true;
2024-11-11 14:25:00 +01:00
package = pkgs.nextcloud30;
configureRedis = true;
config.adminpassFile = config.age.secrets.ncpasswd.path; # Kinda ok just remember to instanly change after first setup
config.adminuser = "admin";
extraApps = with config.services.nextcloud.package.packages.apps; {
2024-07-26 22:12:48 +02:00
inherit
contacts
calendar
tasks
notes
phonetrack
user_oidc
;
2023-12-03 15:15:42 +01:00
};
maxUploadSize = "4G";
extraAppsEnable = true;
database.createLocally = true;
phpOptions."opcache.interned_strings_buffer" = "32";
2024-02-11 00:40:30 +01:00
settings = {
default_phone_region = "DE";
2024-12-20 20:40:27 +01:00
trusted_proxies = [ nodes.nucnix-nginx.config.wireguard.services.ipv4 ];
overwriteprotocol = "https";
2024-02-11 00:40:30 +01:00
maintenance_window_start = 2;
enabledPreviewProviders = [
"OC\\Preview\\BMP"
"OC\\Preview\\GIF"
"OC\\Preview\\JPEG"
"OC\\Preview\\Krita"
"OC\\Preview\\MarkDown"
"OC\\Preview\\MP3"
"OC\\Preview\\OpenDocument"
"OC\\Preview\\PNG"
"OC\\Preview\\TXT"
"OC\\Preview\\XBitmap"
"OC\\Preview\\HEIC"
2023-12-18 02:11:24 +01:00
];
2024-02-11 00:40:30 +01:00
mail_smtpmode = "smtp";
2024-12-20 20:40:27 +01:00
mail_smtphost = "smtp.${globals.domains.mail_public}";
2024-02-11 00:40:30 +01:00
mail_smtpport = 465;
mail_from_address = "nextcloud";
mail_smtpsecure = "ssl";
2024-12-20 20:40:27 +01:00
mail_domain = globals.domains.mail_public;
2024-02-11 00:40:30 +01:00
mail_smtpauth = true;
2024-12-20 20:40:27 +01:00
mail_smtpname = "nextcloud@${globals.domains.mail_public}";
2024-02-11 00:40:30 +01:00
loglevel = 2;
};
config = {
dbtype = "pgsql";
2023-11-28 00:40:46 +01:00
};
};
2024-07-26 22:12:48 +02:00
systemd.tmpfiles.rules =
let
mailer-passwd-conf = pkgs.writeText "nextcloud-config.php" ''
<?php
$CONFIG = [
2024-12-07 15:06:07 +01:00
'mail_smtppassword' => trim(file_get_contents('${config.age.secrets.mailnix-passwd.path}')),
2024-07-26 22:12:48 +02:00
];
'';
in
[
"L+ ${config.services.nextcloud.datadir}/config/mailer.config.php - - - - ${mailer-passwd-conf}"
];
2023-12-03 15:15:42 +01:00
2024-12-20 20:40:27 +01:00
wireguard.services = {
client.via = "nucnix";
firewallRuleForNode.nucnix-nginx.allowedTCPPorts = [ 80 ];
2024-03-14 23:08:42 +01:00
};
networking = {
# Use systemd-resolved inside the container
useHostResolvConf = lib.mkForce false;
};
services.resolved.enable = true;
}