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;
|
2024-05-31 21:54:34 +02:00
|
|
|
package = pkgs.nextcloud29;
|
2024-01-03 18:34:33 +01:00
|
|
|
inherit hostName;
|
2024-06-03 15:38:56 +02:00
|
|
|
home = "/tank/nextcloud";
|
2024-01-03 18:34:33 +01:00
|
|
|
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;
|
2024-05-31 22:19:23 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
settings = {
|
|
|
|
default_phone_region = "NO";
|
2024-06-04 17:42:58 +02:00
|
|
|
log_type = "file";
|
2024-06-13 08:34:13 +02:00
|
|
|
overwriteprotocol = "https";
|
|
|
|
trusted_proxies = [ "192.168.10.175" ]; # defiant
|
|
|
|
|
|
|
|
# Docs: https://github.com/pulsejet/nextcloud-oidc-login
|
|
|
|
oidc_login_auto_redirect = true;
|
|
|
|
oidc_login_button_text = "Log in with KeyCloak";
|
|
|
|
oidc_login_client_id = "nextcloud";
|
|
|
|
oidc_login_client_secret = "dont_put_secrets_here_use_secretFile";
|
|
|
|
oidc_login_code_challenge_method = "S256";
|
|
|
|
oidc_login_end_session_redirect' = true;
|
|
|
|
oidc_login_logout_url = "https://cloud.feal.no/apps/oidc_login/oidc";
|
|
|
|
oidc_login_provider_url = "https://iam.feal.no/realms/feal.no";
|
|
|
|
oidc_login_redir_fallback = true;
|
|
|
|
|
|
|
|
oidc_login_attributes = {
|
|
|
|
id = "preferred_username";
|
|
|
|
mail = "email";
|
|
|
|
name = "name";
|
|
|
|
login_filter = "nextcloud-roles";
|
|
|
|
};
|
|
|
|
oidc_login_filter_allowed_values = [ "nextcloud-user" ];
|
|
|
|
oidc_login_disable_registration = false;
|
2024-07-05 23:04:51 +02:00
|
|
|
|
2024-07-26 11:04:39 +02:00
|
|
|
"memories.exiftool" = "${cfg.home}/store-apps/memories/bin-ext/exiftool-amd64-glibc";
|
|
|
|
"memories.exiftool_no_local" = false;
|
|
|
|
"memories.vod.disable" = false;
|
|
|
|
"memories.vod.ffmpeg" = "${lib.getExe pkgs.ffmpeg-headless}";
|
|
|
|
"memories.vod.ffprobe" = "${pkgs.ffmpeg-headless}/bin/ffprobe";
|
2024-07-05 23:04:51 +02:00
|
|
|
preview_ffmpeg_path = "${pkgs.ffmpeg-headless}/bin/ffmpeg";
|
2024-01-03 02:35:57 +01:00
|
|
|
};
|
|
|
|
|
2024-06-13 08:34:13 +02:00
|
|
|
secretFile = config.sops.secrets."nextcloud/secretsjson".path;
|
|
|
|
|
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-07-05 23:04:51 +02:00
|
|
|
environment.systemPackages = [
|
|
|
|
cfg.occ # "occ CMD" in the docs -> "sudo -u nextcloud nextcloud-occ CMD"
|
|
|
|
pkgs.nodejs_20 # For Recognize; Put /run/current-system/sw/bin/node in the "node_binary" field in the web UI -> Memories
|
|
|
|
];
|
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-06-13 08:34:13 +02:00
|
|
|
sops.secrets."nextcloud/secretsjson" = {
|
|
|
|
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-07-05 23:04:51 +02:00
|
|
|
systemd.services.nextcloud-cron = {
|
2024-07-26 11:04:39 +02:00
|
|
|
path = with pkgs; [
|
|
|
|
exiftool
|
|
|
|
ffmpeg-headless
|
|
|
|
];
|
2024-07-05 23:04:51 +02: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" = {
|
2024-06-03 15:38:56 +02:00
|
|
|
requires = [ "tank-nextcloud.mount" ];
|
2024-07-26 11:04:39 +02:00
|
|
|
path = with pkgs; [
|
|
|
|
# perl
|
|
|
|
# perlPackages.ImageExifTool
|
|
|
|
exiftool
|
|
|
|
ffmpeg-headless
|
|
|
|
];
|
2024-02-08 14:45:56 +01:00
|
|
|
serviceConfig = {
|
2024-07-05 23:04:51 +02:00
|
|
|
PrivateDevices = lib.mkForce false;
|
2024-06-03 15:38:56 +02:00
|
|
|
WorkingDirectory = "/tank/nextcloud";
|
2024-07-05 23:04:51 +02:00
|
|
|
|
2024-02-08 14:45:56 +01:00
|
|
|
NoNewPrivileges = true;
|
|
|
|
PrivateMounts = true;
|
|
|
|
PrivateTmp = true;
|
|
|
|
ProtectClock = true;
|
|
|
|
ProtectHome = true;
|
|
|
|
ProtectHostname = true;
|
|
|
|
ProtectKernelLogs = true;
|
|
|
|
ProtectKernelModules = true;
|
|
|
|
ProtectKernelTunables = true;
|
|
|
|
ProtectProc = "invisible";
|
2024-06-03 15:38:56 +02:00
|
|
|
ReadWritePaths = [ "/tank/nextcloud" "/run/phpfpm" "/run/systemd" ];
|
2024-06-13 08:34:13 +02:00
|
|
|
ReadOnlyPaths = [ "/run/secrets" "/nix/store" ];
|
2024-07-03 23:48:10 +02:00
|
|
|
InaccessbilePaths = [ "/tank/media" "/tank/backup" ];
|
2024-02-08 14:45:56 +01:00
|
|
|
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-07-05 23:04:51 +02:00
|
|
|
|
|
|
|
# Notes:
|
|
|
|
# - Install Memories and Recognize from the app store
|
|
|
|
# - They might need to be forced on with "nextcloud-occ app:enable memories", etc.
|
|
|
|
# - Run "nextcloud-occ maintenance:repair" to fix broken paths
|
|
|
|
# - Download ai models and maps with the commands given in the ui
|
|
|
|
# - libtensorflow doesn't work properly through node, but recognize still works(?)
|
2024-01-03 02:35:57 +01:00
|
|
|
}
|