2024-01-03 02:35:57 +01:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
let
|
2024-01-03 18:34:33 +01:00
|
|
|
cfg = config.services.nextcloud;
|
2024-01-03 02:35:57 +01:00
|
|
|
hostName = "cloud.feal.no";
|
|
|
|
in {
|
2024-01-03 18:34:33 +01:00
|
|
|
services.nextcloud = {
|
|
|
|
enable = true;
|
|
|
|
package = pkgs.nextcloud28;
|
|
|
|
inherit hostName;
|
|
|
|
home = "/var/lib/nextcloud";
|
|
|
|
https = true;
|
|
|
|
webfinger = true;
|
2024-01-03 02:35:57 +01:00
|
|
|
|
2024-01-03 18:34:33 +01:00
|
|
|
config = {
|
|
|
|
dbtype = "pgsql";
|
|
|
|
dbuser = "nextcloud";
|
|
|
|
dbhost = "/run/postgresql";
|
|
|
|
dbname = "nextcloud";
|
|
|
|
adminuser = "ncadmin";
|
|
|
|
adminpassFile = config.sops.secrets."nextcloud/adminpass".path;
|
|
|
|
trustedProxies = [ "192.168.10.175" ]; # defiant
|
|
|
|
defaultPhoneRegion = "NO";
|
2024-01-03 02:35:57 +01:00
|
|
|
};
|
|
|
|
|
2024-01-06 15:28:31 +01:00
|
|
|
phpOptions = {
|
|
|
|
"opcache.interned_strings_buffer" = "16";
|
|
|
|
"upload_max_filesize" = lib.mkForce "8G";
|
|
|
|
"post_max_size" = lib.mkForce "8G";
|
|
|
|
"memory_limit" = lib.mkForce "8G";
|
|
|
|
};
|
2024-01-03 02:35:57 +01:00
|
|
|
|
2024-01-03 18:34:33 +01:00
|
|
|
poolSettings = {
|
|
|
|
"pm" = "ondemand";
|
|
|
|
"pm.max_children" = 32;
|
|
|
|
"pm.process_idle_timeout" = "10s";
|
|
|
|
"pm.max_requests" = 500;
|
|
|
|
};
|
|
|
|
};
|
2024-01-03 02:35:57 +01:00
|
|
|
|
2024-01-03 18:34:33 +01:00
|
|
|
environment.systemPackages = [ cfg.occ ];
|
2024-01-03 02:35:57 +01:00
|
|
|
|
2024-01-03 18:34:33 +01:00
|
|
|
sops.secrets."nextcloud/adminpass" = {
|
|
|
|
mode = "0440";
|
|
|
|
owner = "nextcloud";
|
|
|
|
group = "nextcloud";
|
|
|
|
restartUnits = [ "phpfpm-nextcloud.service" ];
|
|
|
|
};
|
2024-01-03 02:35:57 +01:00
|
|
|
|
2024-01-03 18:34:33 +01:00
|
|
|
services.postgresql = {
|
|
|
|
ensureDatabases = [ "nextcloud" ];
|
|
|
|
ensureUsers = [ {
|
|
|
|
name = "nextcloud";
|
|
|
|
ensureDBOwnership = true;
|
|
|
|
} ];
|
|
|
|
};
|
2024-01-03 02:35:57 +01:00
|
|
|
|
2024-01-03 18:34:33 +01:00
|
|
|
systemd.services."nextcloud-setup" = {
|
|
|
|
requires = [ "postgresql.service" ];
|
|
|
|
after = [ "postgresql.service" ];
|
|
|
|
};
|
2024-01-03 02:35:57 +01:00
|
|
|
|
2024-02-08 14:45:56 +01:00
|
|
|
systemd.services."phpfpm-nextcloud" = {
|
|
|
|
requires = [ "var-lib-nextcloud.mount" ];
|
|
|
|
serviceConfig = {
|
|
|
|
WorkingDirectory = "/var/lib/nextcloud";
|
|
|
|
NoNewPrivileges = true;
|
|
|
|
PrivateDevices = true;
|
|
|
|
PrivateMounts = true;
|
|
|
|
PrivateTmp = true;
|
|
|
|
ProtectClock = true;
|
|
|
|
ProtectHome = true;
|
|
|
|
ProtectHostname = true;
|
|
|
|
ProtectKernelLogs = true;
|
|
|
|
ProtectKernelModules = true;
|
|
|
|
ProtectKernelTunables = true;
|
|
|
|
ProtectProc = "invisible";
|
|
|
|
ReadWritePaths = [ "/var/lib/nextcloud" "/run/phpfpm" "/run/systemd" "/run/secrets" "/nix/store" ];
|
|
|
|
RemoveIPC = true;
|
|
|
|
RestrictSUIDSGID = true;
|
|
|
|
UMask = "0007";
|
|
|
|
SystemCallArchitectures = "native";
|
|
|
|
SystemCallFilter = "@system-service";
|
|
|
|
CapabilityBoundingSet = "~CAP_FSETID ~CAP_SETFCAP ~CAP_SETUID ~CAP_SETGID ~CAP_SETPCAP ~CAP_NET_ADMIN ~CAP_SYS_ADMIN ~CAP_SYS_PTRACE ";
|
|
|
|
};
|
2024-01-03 18:34:33 +01:00
|
|
|
};
|
2024-01-03 02:35:57 +01:00
|
|
|
|
2024-01-03 18:34:33 +01:00
|
|
|
fileSystems."/var/lib/nextcloud" = {
|
|
|
|
device = "/tank/nextcloud";
|
|
|
|
options = [ "bind "];
|
2024-01-03 02:35:57 +01:00
|
|
|
};
|
|
|
|
}
|