This commit is contained in:
aloslider committed 2026-10-01 13:59:54 +03:00
1 parent 13e407847f
commit 374428658a
80 files changed
+2517 -1058

No files matched your search

@@ -0,0 +1,19 @@
{ config, lib, ... }:
with lib;
let
rootCfg = config.selfhosted.seafile;
cfg = rootCfg.collabora;
domain = config.sops.placeholder."domains/serv";
seafileUrl = "https://${rootCfg.server.subdomain}.${domain}";
in
{
config = mkIf rootCfg.enable {
sops.templates."collabora.env".content = ''
TZ=${config.time.timeZone}
DONT_GEN_SSL_CERT=true
server_name=${cfg.subdomain}.${domain}
aliasgroup1=${seafileUrl}:443
extra_params=--o:ssl.enable=false --o:ssl.termination=true --o:net.frame_ancestors=${seafileUrl} --o:logging.level=warning
'';
};
}
@@ -0,0 +1,47 @@
{ config, lib, ... }:
with lib;
let
common = config.selfhosted.common;
rootCfg = config.selfhosted.seafile;
cfg = rootCfg.collabora;
in
{
imports = [ ./config.nix ];
options.selfhosted.seafile.collabora = {
name = mkOption {
type = types.str;
};
subdomain = mkOption {
type = types.str;
};
hostHttpPort = mkOption {
type = types.port;
};
};
config = mkIf rootCfg.enable {
virtualisation.oci-containers.containers.${cfg.name} = {
image = "docker.io/collabora/code:26.04.3.1.1";
ports = [
"0.0.0.0:${toString cfg.hostHttpPort}:9980"
];
environmentFiles = [ config.sops.templates."collabora.env".path ];
log-driver = "journald";
extraOptions = [
"--network=${common.network.name}"
"--cap-add=MKNOD"
];
};
systemd.services."${common.backend}-${cfg.name}" = {
serviceConfig = {
Restart = lib.mkOverride 90 "always";
};
wantedBy = [ "${common.backend}-${rootCfg.targetName}.target" ];
partOf = [ "${common.backend}-${rootCfg.targetName}.target" ];
after = [ "${common.backend}-${rootCfg.server.name}.service" ];
requires = [ "${common.backend}-${rootCfg.server.name}.service" ];
};
};
}
@@ -6,28 +6,40 @@ let
in
{
imports = [
./collabora
./mariadb
./notification
./redis
./seadoc
./server
./thumbnail
];
options.selfhosted.seafile = {
enable = mkEnableOption "Enable ${cfg.targetName} root target";
targetName = mkOption {
type = types.str;
};
};
config = {
config = mkIf cfg.enable {
sops.secrets = {
"seafile/admin_email" = { };
"seafile/admin_password" = { };
"seafile/client_id" = { };
"seafile/client_secret" = { };
"seafile/jwt_private_key" = { };
"seafile/mysql_password" = { };
"seafile/redis_password" = { };
};
systemd.targets."${common.backend}-${cfg.targetName}" = {
unitConfig = {
Description = "Root target for ${cfg.targetName}";
};
after = [ "${common.backend}-network-${common.network.name}.service" ];
requires = [ "${common.backend}-network-${common.network.name}.service" ];
partOf = [ "${common.backend}-${common.rootTarget.name}.target" ];
wantedBy = [ "${common.backend}-${common.rootTarget.name}.target" ];
partOf = [ "${common.backend}-${common.rootTarget.name}.target" ];
after = [ "${common.backend}-${common.rootTarget.name}.target" ];
};
};
}
@@ -1,12 +1,14 @@
{ config, ... }:
{ config, lib, ... }:
with lib;
let
rootCfg = config.selfhosted.seafile;
in
{
sops.secrets = {
"seafile/mysql_password" = { };
config = mkIf rootCfg.enable {
sops.templates."seafile-db.env".content = ''
MYSQL_ROOT_PASSWORD=${config.sops.placeholder."seafile/mysql_password"}
MYSQL_LOG_CONSOLE=true
MARIADB_AUTO_UPGRADE=1
'';
};
sops.templates."seafile-db.env".content = ''
MYSQL_ROOT_PASSWORD=${config.sops.placeholder."seafile/mysql_password"}
MYSQL_LOG_CONSOLE=true
MARIADB_AUTO_UPGRADE=1
'';
}
@@ -2,7 +2,8 @@
with lib;
let
common = config.selfhosted.common;
cfg = config.selfhosted.seafile;
rootCfg = config.selfhosted.seafile;
cfg = rootCfg.mariadb;
hostDataPath = "${common.dataDir}/seafile";
in
{
@@ -14,8 +15,8 @@ in
};
};
config = {
virtualisation.oci-containers.containers.${cfg.mariadb.name} = {
config = mkIf rootCfg.enable {
virtualisation.oci-containers.containers.${cfg.name} = {
image = "docker.io/mariadb:10.11";
environmentFiles = [ config.sops.templates."seafile-db.env".path ];
volumes = [
@@ -32,14 +33,12 @@ in
];
};
systemd.services."${common.backend}-${cfg.mariadb.name}" = {
systemd.services."${common.backend}-${cfg.name}" = {
serviceConfig = {
Restart = lib.mkOverride 90 "always";
};
after = [ "${common.backend}-network-${common.network.name}.service" ];
requires = [ "${common.backend}-network-${common.network.name}.service" ];
partOf = [ "${common.backend}-${cfg.targetName}.target" ];
wantedBy = [ "${common.backend}-${cfg.targetName}.target" ];
wantedBy = [ "${common.backend}-${rootCfg.targetName}.target" ];
partOf = [ "${common.backend}-${rootCfg.targetName}.target" ];
preStart = ''
mkdir -p ${hostDataPath}/mysql
'';
@@ -1,17 +1,20 @@
{ config, ... }:
{ config, lib, ... }:
with lib;
let
cfg = config.selfhosted.seafile;
rootCfg = config.selfhosted.seafile;
in
{
sops.templates."seafile-notification.env".content = ''
SEAFILE_MYSQL_DB_HOST=${cfg.mariadb.name}
SEAFILE_MYSQL_DB_PORT=3306
SEAFILE_MYSQL_DB_USER=seafile
SEAFILE_MYSQL_DB_PASSWORD=${config.sops.placeholder."seafile/mysql_password"}
SEAFILE_MYSQL_DB_CCNET_DB_NAME=ccnet_db
SEAFILE_MYSQL_DB_SEAFILE_DB_NAME=seafile_db
JWT_PRIVATE_KEY=${config.sops.placeholder."seafile/jwt_private_key"}
SEAFILE_LOG_TO_STDOUT=false
NOTIFICATION_SERVER_LOG_LEVEL=info
'';
config = mkIf rootCfg.enable {
sops.templates."seafile-notification.env".content = ''
SEAFILE_MYSQL_DB_HOST=${rootCfg.mariadb.name}
SEAFILE_MYSQL_DB_PORT=3306
SEAFILE_MYSQL_DB_USER=seafile
SEAFILE_MYSQL_DB_PASSWORD=${config.sops.placeholder."seafile/mysql_password"}
SEAFILE_MYSQL_DB_CCNET_DB_NAME=ccnet_db
SEAFILE_MYSQL_DB_SEAFILE_DB_NAME=seafile_db
JWT_PRIVATE_KEY=${config.sops.placeholder."seafile/jwt_private_key"}
SEAFILE_LOG_TO_STDOUT=false
NOTIFICATION_SERVER_LOG_LEVEL=info
'';
};
}
@@ -2,7 +2,8 @@
with lib;
let
common = config.selfhosted.common;
cfg = config.selfhosted.seafile;
rootCfg = config.selfhosted.seafile;
cfg = rootCfg.notification;
hostDataPath = "${common.dataDir}/seafile";
in
{
@@ -17,11 +18,11 @@ in
};
};
config = {
virtualisation.oci-containers.containers.${cfg.notification.name} = {
config = mkIf rootCfg.enable {
virtualisation.oci-containers.containers.${cfg.name} = {
image = "docker.io/seafileltd/notification-server:13.0-latest";
ports = [
"0.0.0.0:${toString cfg.notification.hostHttpPort}:8083"
"0.0.0.0:${toString cfg.hostHttpPort}:8083"
];
environmentFiles = [ config.sops.templates."seafile-notification.env".path ];
volumes = [
@@ -33,29 +34,25 @@ in
];
};
systemd.services."${common.backend}-${cfg.notification.name}" = {
systemd.services."${common.backend}-${cfg.name}" = {
serviceConfig = {
Restart = lib.mkOverride 90 "always";
};
after = [
"${common.backend}-network-${common.network.name}.service"
"${common.backend}-${config.selfhosted.traefik.name}.service"
"${common.backend}-${cfg.mariadb.name}.service"
"${common.backend}-${cfg.server.name}.service"
];
wantedBy = [ "${common.backend}-${rootCfg.targetName}.target" ];
partOf = [ "${common.backend}-${rootCfg.targetName}.target" ];
requires = [
"${common.backend}-network-${common.network.name}.service"
"${common.backend}-${config.selfhosted.traefik.name}.service"
"${common.backend}-${cfg.mariadb.name}.service"
"${common.backend}-${cfg.server.name}.service"
"${common.backend}-${rootCfg.mariadb.name}.service"
"${common.backend}-${rootCfg.server.name}.service"
];
after = [
"${common.backend}-${rootCfg.mariadb.name}.service"
"${common.backend}-${rootCfg.server.name}.service"
];
partOf = [ "${common.backend}-${cfg.targetName}.target" ];
wantedBy = [ "${common.backend}-${cfg.targetName}.target" ];
path = with pkgs; [ curl gawk ];
preStart = ''
echo "Waiting for Seafile server to be ready..."
for i in {1..60}; do
status=$(curl -sI --max-time 5 "http://localhost:${toString cfg.server.hostHttpPort}" | head -1 | awk '{print $2}')
status=$(curl -sI --max-time 5 "http://localhost:${toString rootCfg.server.hostHttpPort}" | head -1 | awk '{print $2}')
if [[ "$status" =~ ^(200|301|302)$ ]]; then
echo "Seafile server is up (HTTP $status, attempt $i)"
@@ -1,10 +1,12 @@
{ config, ... }:
{ config, lib, ... }:
with lib;
let
rootCfg = config.selfhosted.seafile;
in
{
sops.secrets = {
"seafile/redis_password" = { };
config = mkIf rootCfg.enable {
sops.templates."seafile-redis.env".content = ''
REDIS_PASSWORD=${config.sops.placeholder."seafile/redis_password"}
'';
};
sops.templates."seafile-redis.env".content = ''
REDIS_PASSWORD=${config.sops.placeholder."seafile/redis_password"}
'';
}
@@ -2,7 +2,8 @@
with lib;
let
common = config.selfhosted.common;
cfg = config.selfhosted.seafile;
rootCfg = config.selfhosted.seafile;
cfg = rootCfg.redis;
in
{
imports = [ ./config.nix ];
@@ -13,8 +14,8 @@ in
};
};
config = {
virtualisation.oci-containers.containers.${cfg.redis.name} = {
config = mkIf rootCfg.enable {
virtualisation.oci-containers.containers.${cfg.name} = {
image = "docker.io/redis:7";
environmentFiles = [ config.sops.templates."seafile-redis.env".path ];
cmd = [ "/bin/sh" "-c" "exec redis-server --requirepass \"$REDIS_PASSWORD\"" ];
@@ -24,14 +25,12 @@ in
];
};
systemd.services."${common.backend}-${cfg.redis.name}" = {
systemd.services."${common.backend}-${cfg.name}" = {
serviceConfig = {
Restart = lib.mkOverride 90 "always";
};
after = [ "${common.backend}-network-${common.network.name}.service" ];
requires = [ "${common.backend}-network-${common.network.name}.service" ];
partOf = [ "${common.backend}-${cfg.targetName}.target" ];
wantedBy = [ "${common.backend}-${cfg.targetName}.target" ];
wantedBy = [ "${common.backend}-${rootCfg.targetName}.target" ];
partOf = [ "${common.backend}-${rootCfg.targetName}.target" ];
};
};
}
@@ -1,17 +1,20 @@
{ config, ... }:
{ config, lib, ... }:
with lib;
let
cfg = config.selfhosted.seafile;
rootCfg = config.selfhosted.seafile;
in
{
sops.templates."seadoc.env".content = ''
DB_HOST=${cfg.mariadb.name}
DB_PORT=3306
DB_USER=seafile
DB_PASSWORD=${config.sops.placeholder."seafile/mysql_password"}
DB_NAME=seahub_db
TIME_ZONE=${config.time.timeZone}
JWT_PRIVATE_KEY=${config.sops.placeholder."seafile/jwt_private_key"}
NON_ROOT=false
SEAHUB_SERVICE_URL=http://${cfg.server.name}
'';
config = mkIf rootCfg.enable {
sops.templates."seadoc.env".content = ''
DB_HOST=${rootCfg.mariadb.name}
DB_PORT=3306
DB_USER=seafile
DB_PASSWORD=${config.sops.placeholder."seafile/mysql_password"}
DB_NAME=seahub_db
TIME_ZONE=${config.time.timeZone}
JWT_PRIVATE_KEY=${config.sops.placeholder."seafile/jwt_private_key"}
NON_ROOT=false
SEAHUB_SERVICE_URL=http://${rootCfg.server.name}
'';
};
}
@@ -2,7 +2,8 @@
with lib;
let
common = config.selfhosted.common;
cfg = config.selfhosted.seafile;
rootCfg = config.selfhosted.seafile;
cfg = rootCfg.seadoc;
hostDataPath = "${common.dataDir}/seafile";
in
{
@@ -17,11 +18,11 @@ in
};
};
config = {
virtualisation.oci-containers.containers.${cfg.seadoc.name} = {
config = mkIf rootCfg.enable {
virtualisation.oci-containers.containers.${cfg.name} = {
image = "docker.io/seafileltd/sdoc-server:2.0-latest";
ports = [
"0.0.0.0:${toString cfg.seadoc.hostHttpPort}:80"
"0.0.0.0:${toString cfg.hostHttpPort}:80"
];
volumes = [
"${hostDataPath}/seadoc/shared:/shared"
@@ -33,22 +34,14 @@ in
];
};
systemd.services."${common.backend}-${cfg.seadoc.name}" = {
systemd.services."${common.backend}-${cfg.name}" = {
serviceConfig = {
Restart = lib.mkOverride 90 "always";
};
after = [
"${common.backend}-network-${common.network.name}.service"
"${common.backend}-${config.selfhosted.traefik.name}.service"
"${common.backend}-${cfg.mariadb.name}.service"
];
requires = [
"${common.backend}-network-${common.network.name}.service"
"${common.backend}-${config.selfhosted.traefik.name}.service"
"${common.backend}-${cfg.mariadb.name}.service"
];
partOf = [ "${common.backend}-${cfg.targetName}.target" ];
wantedBy = [ "${common.backend}-${cfg.targetName}.target" ];
wantedBy = [ "${common.backend}-${rootCfg.targetName}.target" ];
partOf = [ "${common.backend}-${rootCfg.targetName}.target" ];
requires = [ "${common.backend}-${rootCfg.mariadb.name}.service" ];
after = [ "${common.backend}-${rootCfg.mariadb.name}.service" ];
preStart = ''
mkdir -p ${hostDataPath}/seadoc/shared
'';
@@ -1,103 +1,122 @@
{ config, ... }:
{ config, lib, ... }:
with lib;
let
cfg = config.selfhosted.seafile;
rootCfg = config.selfhosted.seafile;
poCfg = config.selfhosted.pocket-id;
domain = config.sops.placeholder."domains/serv";
in
{
sops.secrets = {
"seafile/admin_email" = { };
"seafile/admin_password" = { };
"seafile/client_id" = { };
"seafile/client_secret" = { };
"seafile/jwt_private_key" = { };
config = mkIf rootCfg.enable {
sops.templates."seafile.env".content = ''
SEAFILE_MYSQL_DB_HOST=${rootCfg.mariadb.name}
SEAFILE_MYSQL_DB_PORT=3306
SEAFILE_MYSQL_DB_USER=seafile
SEAFILE_MYSQL_DB_PASSWORD=${config.sops.placeholder."seafile/mysql_password"}
SEAFILE_MYSQL_DB_CCNET_DB_NAME=ccnet_db
SEAFILE_MYSQL_DB_SEAFILE_DB_NAME=seafile_db
SEAFILE_MYSQL_DB_SEAHUB_DB_NAME=seahub_db
TIME_ZONE=${config.time.timeZone}
INIT_SEAFILE_MYSQL_ROOT_PASSWORD=${config.sops.placeholder."seafile/mysql_password"}
INIT_SEAFILE_ADMIN_EMAIL=${config.sops.placeholder."seafile/admin_email"}
INIT_SEAFILE_ADMIN_PASSWORD=${config.sops.placeholder."seafile/admin_password"}
SEAFILE_SERVER_HOSTNAME=${rootCfg.server.subdomain}.${domain}
SEAFILE_SERVER_PROTOCOL=https
SEAFILE_SERVER_LETSENCRYPT=false
SITE_ROOT=/
NON_ROOT=false
JWT_PRIVATE_KEY=${config.sops.placeholder."seafile/jwt_private_key"}
SEAFILE_LOG_TO_STDOUT=false
ENABLE_GO_FILESERVER=true
CACHE_PROVIDER=redis
REDIS_HOST=${rootCfg.redis.name}
REDIS_PORT=6379
REDIS_PASSWORD=${config.sops.placeholder."seafile/redis_password"}
ENABLE_NOTIFICATION_SERVER=true
INNER_NOTIFICATION_SERVER_URL=http://${rootCfg.notification.name}:8083
NOTIFICATION_SERVER_URL=https://${rootCfg.server.subdomain}.${domain}/notification
ENABLE_SEAFILE_AI=false
MD_FILE_COUNT_LIMIT=100000
'';
sops.templates."seahub_settings.py".content = ''
ENABLE_VIDEO_THUMBNAIL = True
SERVICE_URL = "https://${rootCfg.server.subdomain}.${domain}"
FILE_SERVER_ROOT = "https://${rootCfg.server.subdomain}.${domain}/seafhttp"
ENABLE_OAUTH = True
OAUTH_CREATE_UNKNOWN_USER = True
OAUTH_ACTIVATE_USER_AFTER_CREATION = True
OAUTH_ENABLE_INSECURE_TRANSPORT = False
OAUTH_CLIENT_ID = "${config.sops.placeholder."seafile/client_id"}"
OAUTH_CLIENT_SECRET = "${config.sops.placeholder."seafile/client_secret"}"
OAUTH_REDIRECT_URL = "https://${rootCfg.server.subdomain}.${domain}/oauth/callback"
OAUTH_PROVIDER = "pocket-id"
OAUTH_PROVIDER_DOMAIN = "pocket-id"
OAUTH_AUTHORIZATION_URL = "https://${poCfg.subdomain}.${domain}/authorize"
OAUTH_TOKEN_URL = "https://${poCfg.subdomain}.${domain}/api/oidc/token"
OAUTH_USER_INFO_URL = "https://${poCfg.subdomain}.${domain}/api/oidc/userinfo"
OAUTH_SCOPE = [
"openid",
"profile",
"email"
]
OAUTH_ATTRIBUTE_MAP = {
"sub": (True, "uid"),
"name": (False, "name"),
"email": (False, "contact_email"),
}
CLIENT_SSO_VIA_LOCAL_BROWSER = True
ENABLE_SEADOC = True
SEADOC_SERVER_URL = "https://${rootCfg.server.subdomain}.${domain}/sdoc-server"
OFFICE_SERVER_TYPE = "CollaboraOffice"
ENABLE_OFFICE_WEB_APP = True
OFFICE_WEB_APP_BASE_URL = "http://${rootCfg.collabora.name}:9980/hosting/discovery"
WOPI_ACCESS_TOKEN_EXPIRATION = 10 * 60 * 60
OFFICE_WEB_APP_FILE_EXTENSION = (
"odp", "ods", "odt",
"xls", "xlsb", "xlsm", "xlsx",
"ppsx", "ppt", "pptm", "pptx",
"doc", "docm", "docx",
)
ENABLE_OFFICE_WEB_APP_EDIT = True
OFFICE_WEB_APP_EDIT_FILE_EXTENSION = (
"odp", "ods", "odt",
"xls", "xlsb", "xlsm", "xlsx",
"ppsx", "ppt", "pptm", "pptx",
"doc", "docm", "docx",
)
ENABLE_WEBDAV_SECRET = True
WEBDAV_SECRET_MIN_LENGTH = 8
USE_X_FORWARDED_HOST = True
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
ALLOWED_HOSTS = [
".${domain}" ,
"127.0.0.1",
"localhost",
"${rootCfg.server.name}",
]
CSRF_COOKIE_SECURE = True
CSRF_COOKIE_SAMESITE = "Lax"
CSRF_TRUSTED_ORIGINS = [
"https://${rootCfg.server.subdomain}.${domain}"
]
'';
sops.templates."seafdav.conf".content = ''
[WEBDAV]
enabled = true
port = 8080
debug = true
share_name = /seafdav
workers = 5
timeout = 1200
'';
sops.templates."seafile.conf".content = ''
[quota]
default = 100
'';
};
sops.templates."seafile.env".content = ''
SEAFILE_MYSQL_DB_HOST=${cfg.mariadb.name}
SEAFILE_MYSQL_DB_PORT=3306
SEAFILE_MYSQL_DB_USER=seafile
SEAFILE_MYSQL_DB_PASSWORD=${config.sops.placeholder."seafile/mysql_password"}
SEAFILE_MYSQL_DB_CCNET_DB_NAME=ccnet_db
SEAFILE_MYSQL_DB_SEAFILE_DB_NAME=seafile_db
SEAFILE_MYSQL_DB_SEAHUB_DB_NAME=seahub_db
TIME_ZONE=${config.time.timeZone}
INIT_SEAFILE_MYSQL_ROOT_PASSWORD=${config.sops.placeholder."seafile/mysql_password"}
INIT_SEAFILE_ADMIN_EMAIL=${config.sops.placeholder."seafile/admin_email"}
INIT_SEAFILE_ADMIN_PASSWORD=${config.sops.placeholder."seafile/admin_password"}
SEAFILE_SERVER_HOSTNAME=${cfg.server.subdomain}.${domain}
SEAFILE_SERVER_PROTOCOL=https
SEAFILE_SERVER_LETSENCRYPT=false
SITE_ROOT=/
NON_ROOT=false
JWT_PRIVATE_KEY=${config.sops.placeholder."seafile/jwt_private_key"}
SEAFILE_LOG_TO_STDOUT=false
ENABLE_GO_FILESERVER=true
ENABLE_SEADOC=true
SEADOC_SERVER_URL=https://${cfg.server.subdomain}.${domain}/sdoc-server
CACHE_PROVIDER=redis
REDIS_HOST=${cfg.redis.name}
REDIS_PORT=6379
REDIS_PASSWORD=${config.sops.placeholder."seafile/redis_password"}
ENABLE_NOTIFICATION_SERVER=true
INNER_NOTIFICATION_SERVER_URL=http://${cfg.notification.name}:8083
NOTIFICATION_SERVER_URL=https://${cfg.server.subdomain}.${domain}/notification
ENABLE_SEAFILE_AI=false
MD_FILE_COUNT_LIMIT=100000
'';
sops.templates."seahub_settings.py".content = ''
ENABLE_VIDEO_THUMBNAIL = True
ENABLE_OAUTH = True
OAUTH_CREATE_UNKNOWN_USER = True
OAUTH_ACTIVATE_USER_AFTER_CREATION = True
OAUTH_ENABLE_INSECURE_TRANSPORT = False
OAUTH_CLIENT_ID = "${config.sops.placeholder."seafile/client_id"}"
OAUTH_CLIENT_SECRET = "${config.sops.placeholder."seafile/client_secret"}"
OAUTH_REDIRECT_URL = "https://${cfg.server.subdomain}.${domain}/oauth/callback"
OAUTH_PROVIDER = "pocket-id"
OAUTH_PROVIDER_DOMAIN = "pocket-id"
OAUTH_AUTHORIZATION_URL = "https://${poCfg.subdomain}.${domain}/authorize"
OAUTH_TOKEN_URL = "https://${poCfg.subdomain}.${domain}/api/oidc/token"
OAUTH_USER_INFO_URL = "https://${poCfg.subdomain}.${domain}/api/oidc/userinfo"
OAUTH_SCOPE = [
"openid",
"profile",
"email"
]
OAUTH_ATTRIBUTE_MAP = {
"sub": (True, "uid"),
"name": (False, "name"),
"email": (False, "contact_email"),
}
CLIENT_SSO_VIA_LOCAL_BROWSER = True
ENABLE_WEBDAV_SECRET = True
WEBDAV_SECRET_MIN_LENGTH = 8
SERVICE_URL = "https://${cfg.server.subdomain}.${domain}"
USE_X_FORWARDED_HOST = True
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
ALLOWED_HOSTS = [".${domain}"]
CSRF_COOKIE_SECURE = True
CSRF_COOKIE_SAMESITE = "Lax"
CSRF_TRUSTED_ORIGINS = [
"https://${cfg.server.subdomain}.${domain}"
]
'';
sops.templates."seafdav.conf".content = ''
[WEBDAV]
enabled = true
port = 8080
debug = true
share_name = /seafdav
workers = 5
timeout = 1200
'';
sops.templates."seafile.conf".content = ''
[quota]
default = 100
'';
}
@@ -2,7 +2,8 @@
with lib;
let
common = config.selfhosted.common;
cfg = config.selfhosted.seafile;
rootCfg = config.selfhosted.seafile;
cfg = rootCfg.server;
hostDataPath = "${common.dataDir}/seafile";
in
{
@@ -20,11 +21,11 @@ in
};
};
config = {
virtualisation.oci-containers.containers.${cfg.server.name} = {
config = mkIf rootCfg.enable {
virtualisation.oci-containers.containers.${cfg.name} = {
image = "docker.io/seafileltd/seafile-mc:13.0-latest";
ports = [
"0.0.0.0:${toString cfg.server.hostHttpPort}:80"
"0.0.0.0:${toString cfg.hostHttpPort}:80"
];
environmentFiles = [ config.sops.templates."seafile.env".path ];
volumes = [
@@ -36,24 +37,20 @@ in
];
};
systemd.services."${common.backend}-${cfg.server.name}" = {
systemd.services."${common.backend}-${cfg.name}" = {
serviceConfig = {
Restart = lib.mkOverride 90 "always";
};
after = [
"${common.backend}-network-${common.network.name}.service"
"${common.backend}-${config.selfhosted.traefik.name}.service"
"${common.backend}-${config.selfhosted.seafile.mariadb.name}.service"
"${common.backend}-${config.selfhosted.seafile.redis.name}.service"
];
wantedBy = [ "${common.backend}-${rootCfg.targetName}.target" ];
partOf = [ "${common.backend}-${rootCfg.targetName}.target" ];
requires = [
"${common.backend}-network-${common.network.name}.service"
"${common.backend}-${config.selfhosted.traefik.name}.service"
"${common.backend}-${cfg.mariadb.name}.service"
"${common.backend}-${cfg.redis.name}.service"
"${common.backend}-${rootCfg.mariadb.name}.service"
"${common.backend}-${rootCfg.redis.name}.service"
];
after = [
"${common.backend}-${rootCfg.mariadb.name}.service"
"${common.backend}-${rootCfg.redis.name}.service"
];
partOf = [ "${common.backend}-${cfg.targetName}.target" ];
wantedBy = [ "${common.backend}-${cfg.targetName}.target" ];
preStart = ''
mkdir -p ${hostDataPath}/server/shared/seafile/conf
@@ -0,0 +1,25 @@
{ config, lib, ... }:
with lib;
let
rootCfg = config.selfhosted.seafile;
in
{
config = mkIf rootCfg.enable {
sops.templates."seafile-thumbnail.env".content = ''
TIME_ZONE=${config.time.timeZone}
SEAFILE_MYSQL_DB_HOST=${rootCfg.mariadb.name}
SEAFILE_MYSQL_DB_PORT=3306
SEAFILE_MYSQL_DB_USER=seafile
SEAFILE_MYSQL_DB_PASSWORD=${config.sops.placeholder."seafile/mysql_password"}
SEAFILE_MYSQL_DB_CCNET_DB_NAME=ccnet_db
SEAFILE_MYSQL_DB_SEAFILE_DB_NAME=seafile_db
NON_ROOT=false
JWT_PRIVATE_KEY=${config.sops.placeholder."seafile/jwt_private_key"}
SEAFILE_LOG_TO_STDOUT=false
SITE_ROOT=/
INNER_SEAHUB_SERVICE_URL=http://${rootCfg.server.name}
THUMBNAIL_IMAGE_ORIGINAL_SIZE_LIMIT=256
SEAF_SERVER_STORAGE_TYPE=disk
'';
};
}
@@ -0,0 +1,53 @@
{ config, lib, ... }:
with lib;
let
common = config.selfhosted.common;
rootCfg = config.selfhosted.seafile;
cfg = rootCfg.thumbnail;
hostDataPath = "${common.dataDir}/seafile";
in
{
imports = [ ./config.nix ];
options.selfhosted.seafile.thumbnail = {
name = mkOption {
type = types.str;
};
hostHttpPort = mkOption {
type = types.port;
};
};
config = mkIf rootCfg.enable {
virtualisation.oci-containers.containers.${cfg.name} = {
image = "docker.io/seafileltd/thumbnail-server:13.0.20";
ports = [
"0.0.0.0:${toString cfg.hostHttpPort}:80"
];
environmentFiles = [ config.sops.templates."seafile-thumbnail.env".path ];
volumes = [
"${hostDataPath}/server/shared:/shared"
];
log-driver = "journald";
extraOptions = [
"--network=${common.network.name}"
];
};
systemd.services."${common.backend}-${cfg.name}" = {
serviceConfig = {
Restart = lib.mkOverride 90 "always";
};
wantedBy = [ "${common.backend}-${rootCfg.targetName}.target" ];
partOf = [ "${common.backend}-${rootCfg.targetName}.target" ];
requires = [
"${common.backend}-${rootCfg.mariadb.name}.service"
"${common.backend}-${rootCfg.server.name}.service"
];
after = [
"${common.backend}-${rootCfg.mariadb.name}.service"
"${common.backend}-${rootCfg.server.name}.service"
];
};
};
}