Small modules config restructure

Changed variables names in every module
This commit is contained in:
aloslider committed 2026-10-31 19:48:50 +03:00
1 parent c1d2e52bf8
commit c92b90e406
83 files changed
+616 -523

No files matched your search

@@ -1,13 +1,13 @@
{ config, lib, ... }:
with lib;
let
rootCfg = config.selfhosted.seafile;
cfg = rootCfg.collabora;
moduleCfg = config.selfhosted.seafile;
cfg = moduleCfg.collabora;
domain = config.sops.placeholder."domains/serv";
seafileUrl = "https://${rootCfg.server.subdomain}.${domain}";
seafileUrl = "https://${moduleCfg.server.subdomain}.${domain}";
in
{
config = mkIf rootCfg.enable {
config = mkIf moduleCfg.enable {
sops.templates."collabora.env".content = ''
TZ=${config.time.timeZone}
DONT_GEN_SSL_CERT=true
@@ -1,9 +1,10 @@
{ config, lib, ... }:
with lib;
let
common = config.selfhosted.common;
rootCfg = config.selfhosted.seafile;
cfg = rootCfg.collabora;
rootCfg = config.selfhosted;
common = rootCfg.common;
moduleCfg = rootCfg.seafile;
cfg = moduleCfg.collabora;
in
{
imports = [ ./config.nix ];
@@ -20,7 +21,7 @@ in
};
};
config = mkIf rootCfg.enable {
config = mkIf moduleCfg.enable {
virtualisation.oci-containers.containers.${cfg.name} = {
image = "docker.io/collabora/code:26.04.3.1.1";
ports = [
@@ -38,10 +39,10 @@ in
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" ];
wantedBy = [ "${common.backend}-${moduleCfg.targetName}.target" ];
partOf = [ "${common.backend}-${moduleCfg.targetName}.target" ];
after = [ "${common.backend}-${moduleCfg.server.name}.service" ];
requires = [ "${common.backend}-${moduleCfg.server.name}.service" ];
};
};
}
@@ -1,8 +1,9 @@
{ config, lib, ... }:
with lib;
let
common = config.selfhosted.common;
cfg = config.selfhosted.seafile;
rootCfg = config.selfhosted;
common = rootCfg.common;
moduleCfg = rootCfg.seafile;
in
{
imports = [
@@ -16,13 +17,13 @@ in
];
options.selfhosted.seafile = {
enable = mkEnableOption "Enable ${cfg.targetName} root target";
enable = mkEnableOption "Enable ${moduleCfg.targetName} root target";
targetName = mkOption {
type = types.str;
};
};
config = mkIf cfg.enable {
config = mkIf moduleCfg.enable {
sops.secrets = {
"seafile/admin_email" = { };
"seafile/admin_password" = { };
@@ -33,9 +34,9 @@ in
"seafile/redis_password" = { };
};
systemd.targets."${common.backend}-${cfg.targetName}" = {
systemd.targets."${common.backend}-${moduleCfg.targetName}" = {
unitConfig = {
Description = "Root target for ${cfg.targetName}";
Description = "Root target for ${moduleCfg.targetName}";
};
wantedBy = [ "${common.backend}-${common.rootTarget.name}.target" ];
partOf = [ "${common.backend}-${common.rootTarget.name}.target" ];
@@ -1,10 +1,10 @@
{ config, lib, ... }:
with lib;
let
rootCfg = config.selfhosted.seafile;
moduleCfg = config.selfhosted.seafile;
in
{
config = mkIf rootCfg.enable {
config = mkIf moduleCfg.enable {
sops.templates."seafile-db.env".content = ''
MYSQL_ROOT_PASSWORD=${config.sops.placeholder."seafile/mysql_password"}
MYSQL_LOG_CONSOLE=true
@@ -1,9 +1,10 @@
{ config, lib, ... }:
with lib;
let
common = config.selfhosted.common;
rootCfg = config.selfhosted.seafile;
cfg = rootCfg.mariadb;
rootCfg = config.selfhosted;
common = rootCfg.common;
moduleCfg = rootCfg.seafile;
cfg = moduleCfg.mariadb;
hostDataPath = "${common.dataDir}/seafile";
in
{
@@ -15,7 +16,7 @@ in
};
};
config = mkIf rootCfg.enable {
config = mkIf moduleCfg.enable {
virtualisation.oci-containers.containers.${cfg.name} = {
image = "docker.io/mariadb:10.11";
environmentFiles = [ config.sops.templates."seafile-db.env".path ];
@@ -37,8 +38,8 @@ in
serviceConfig = {
Restart = lib.mkOverride 90 "always";
};
wantedBy = [ "${common.backend}-${rootCfg.targetName}.target" ];
partOf = [ "${common.backend}-${rootCfg.targetName}.target" ];
wantedBy = [ "${common.backend}-${moduleCfg.targetName}.target" ];
partOf = [ "${common.backend}-${moduleCfg.targetName}.target" ];
preStart = ''
mkdir -p ${hostDataPath}/mysql
'';
@@ -1,12 +1,12 @@
{ config, lib, ... }:
with lib;
let
rootCfg = config.selfhosted.seafile;
moduleCfg = config.selfhosted.seafile;
in
{
config = mkIf rootCfg.enable {
config = mkIf moduleCfg.enable {
sops.templates."seafile-notification.env".content = ''
SEAFILE_MYSQL_DB_HOST=${rootCfg.mariadb.name}
SEAFILE_MYSQL_DB_HOST=${moduleCfg.mariadb.name}
SEAFILE_MYSQL_DB_PORT=3306
SEAFILE_MYSQL_DB_USER=seafile
SEAFILE_MYSQL_DB_PASSWORD=${config.sops.placeholder."seafile/mysql_password"}
@@ -1,9 +1,10 @@
{ config, lib, pkgs, ... }:
with lib;
let
common = config.selfhosted.common;
rootCfg = config.selfhosted.seafile;
cfg = rootCfg.notification;
rootCfg = config.selfhosted;
common = rootCfg.common;
moduleCfg = rootCfg.seafile;
cfg = moduleCfg.notification;
hostDataPath = "${common.dataDir}/seafile";
in
{
@@ -18,7 +19,7 @@ in
};
};
config = mkIf rootCfg.enable {
config = mkIf moduleCfg.enable {
virtualisation.oci-containers.containers.${cfg.name} = {
image = "docker.io/seafileltd/notification-server:13.0-latest";
ports = [
@@ -38,21 +39,21 @@ in
serviceConfig = {
Restart = lib.mkOverride 90 "always";
};
wantedBy = [ "${common.backend}-${rootCfg.targetName}.target" ];
partOf = [ "${common.backend}-${rootCfg.targetName}.target" ];
wantedBy = [ "${common.backend}-${moduleCfg.targetName}.target" ];
partOf = [ "${common.backend}-${moduleCfg.targetName}.target" ];
requires = [
"${common.backend}-${rootCfg.mariadb.name}.service"
"${common.backend}-${rootCfg.server.name}.service"
"${common.backend}-${moduleCfg.mariadb.name}.service"
"${common.backend}-${moduleCfg.server.name}.service"
];
after = [
"${common.backend}-${rootCfg.mariadb.name}.service"
"${common.backend}-${rootCfg.server.name}.service"
"${common.backend}-${moduleCfg.mariadb.name}.service"
"${common.backend}-${moduleCfg.server.name}.service"
];
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 rootCfg.server.hostHttpPort}" | head -1 | awk '{print $2}')
status=$(curl -sI --max-time 5 "http://localhost:${toString moduleCfg.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,10 @@
{ config, lib, ... }:
with lib;
let
rootCfg = config.selfhosted.seafile;
moduleCfg = config.selfhosted.seafile;
in
{
config = mkIf rootCfg.enable {
config = mkIf moduleCfg.enable {
sops.templates."seafile-redis.env".content = ''
REDIS_PASSWORD=${config.sops.placeholder."seafile/redis_password"}
'';
@@ -1,9 +1,10 @@
{ config, lib, ... }:
with lib;
let
common = config.selfhosted.common;
rootCfg = config.selfhosted.seafile;
cfg = rootCfg.redis;
rootCfg = config.selfhosted;
common = rootCfg.common;
moduleCfg = rootCfg.seafile;
cfg = moduleCfg.redis;
in
{
imports = [ ./config.nix ];
@@ -14,7 +15,7 @@ in
};
};
config = mkIf rootCfg.enable {
config = mkIf moduleCfg.enable {
virtualisation.oci-containers.containers.${cfg.name} = {
image = "docker.io/redis:7";
environmentFiles = [ config.sops.templates."seafile-redis.env".path ];
@@ -29,8 +30,8 @@ in
serviceConfig = {
Restart = lib.mkOverride 90 "always";
};
wantedBy = [ "${common.backend}-${rootCfg.targetName}.target" ];
partOf = [ "${common.backend}-${rootCfg.targetName}.target" ];
wantedBy = [ "${common.backend}-${moduleCfg.targetName}.target" ];
partOf = [ "${common.backend}-${moduleCfg.targetName}.target" ];
};
};
}
@@ -1,12 +1,12 @@
{ config, lib, ... }:
with lib;
let
rootCfg = config.selfhosted.seafile;
moduleCfg = config.selfhosted.seafile;
in
{
config = mkIf rootCfg.enable {
config = mkIf moduleCfg.enable {
sops.templates."seadoc.env".content = ''
DB_HOST=${rootCfg.mariadb.name}
DB_HOST=${moduleCfg.mariadb.name}
DB_PORT=3306
DB_USER=seafile
DB_PASSWORD=${config.sops.placeholder."seafile/mysql_password"}
@@ -14,7 +14,7 @@ in
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}
SEAHUB_SERVICE_URL=http://${moduleCfg.server.name}
'';
};
}
@@ -1,9 +1,10 @@
{ config, lib, ... }:
with lib;
let
common = config.selfhosted.common;
rootCfg = config.selfhosted.seafile;
cfg = rootCfg.seadoc;
rootCfg = config.selfhosted;
common = rootCfg.common;
moduleCfg = rootCfg.seafile;
cfg = moduleCfg.seadoc;
hostDataPath = "${common.dataDir}/seafile";
in
{
@@ -18,7 +19,7 @@ in
};
};
config = mkIf rootCfg.enable {
config = mkIf moduleCfg.enable {
virtualisation.oci-containers.containers.${cfg.name} = {
image = "docker.io/seafileltd/sdoc-server:2.0-latest";
ports = [
@@ -38,10 +39,10 @@ in
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" ];
after = [ "${common.backend}-${rootCfg.mariadb.name}.service" ];
wantedBy = [ "${common.backend}-${moduleCfg.targetName}.target" ];
partOf = [ "${common.backend}-${moduleCfg.targetName}.target" ];
requires = [ "${common.backend}-${moduleCfg.mariadb.name}.service" ];
after = [ "${common.backend}-${moduleCfg.mariadb.name}.service" ];
preStart = ''
mkdir -p ${hostDataPath}/seadoc/shared
'';
@@ -1,14 +1,15 @@
{ config, lib, ... }:
with lib;
let
rootCfg = config.selfhosted.seafile;
poCfg = config.selfhosted.pocket-id;
rootCfg = config.selfhosted;
moduleCfg = rootCfg.seafile;
poCfg = rootCfg.pocket-id;
domain = config.sops.placeholder."domains/serv";
in
{
config = mkIf rootCfg.enable {
config = mkIf moduleCfg.enable {
sops.templates."seafile.env".content = ''
SEAFILE_MYSQL_DB_HOST=${rootCfg.mariadb.name}
SEAFILE_MYSQL_DB_HOST=${moduleCfg.mariadb.name}
SEAFILE_MYSQL_DB_PORT=3306
SEAFILE_MYSQL_DB_USER=seafile
SEAFILE_MYSQL_DB_PASSWORD=${config.sops.placeholder."seafile/mysql_password"}
@@ -19,7 +20,7 @@ in
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_HOSTNAME=${moduleCfg.server.subdomain}.${domain}
SEAFILE_SERVER_PROTOCOL=https
SEAFILE_SERVER_LETSENCRYPT=false
SITE_ROOT=/
@@ -28,27 +29,27 @@ in
SEAFILE_LOG_TO_STDOUT=false
ENABLE_GO_FILESERVER=true
CACHE_PROVIDER=redis
REDIS_HOST=${rootCfg.redis.name}
REDIS_HOST=${moduleCfg.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
INNER_NOTIFICATION_SERVER_URL=http://${moduleCfg.notification.name}:8083
NOTIFICATION_SERVER_URL=https://${moduleCfg.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"
SERVICE_URL = "https://${moduleCfg.server.subdomain}.${domain}"
FILE_SERVER_ROOT = "https://${moduleCfg.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_REDIRECT_URL = "https://${moduleCfg.server.subdomain}.${domain}/oauth/callback"
OAUTH_PROVIDER = "pocket-id"
OAUTH_PROVIDER_DOMAIN = "pocket-id"
OAUTH_AUTHORIZATION_URL = "https://${poCfg.subdomain}.${domain}/authorize"
@@ -67,11 +68,11 @@ in
CLIENT_SSO_VIA_LOCAL_BROWSER = True
ENABLE_SEADOC = True
SEADOC_SERVER_URL = "https://${rootCfg.server.subdomain}.${domain}/sdoc-server"
SEADOC_SERVER_URL = "https://${moduleCfg.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"
OFFICE_WEB_APP_BASE_URL = "http://${moduleCfg.collabora.name}:9980/hosting/discovery"
WOPI_ACCESS_TOKEN_EXPIRATION = 10 * 60 * 60
OFFICE_WEB_APP_FILE_EXTENSION = (
"odp", "ods", "odt",
@@ -95,12 +96,12 @@ in
".${domain}" ,
"127.0.0.1",
"localhost",
"${rootCfg.server.name}",
"${moduleCfg.server.name}",
]
CSRF_COOKIE_SECURE = True
CSRF_COOKIE_SAMESITE = "Lax"
CSRF_TRUSTED_ORIGINS = [
"https://${rootCfg.server.subdomain}.${domain}"
"https://${moduleCfg.server.subdomain}.${domain}"
]
'';
@@ -1,9 +1,10 @@
{ config, lib, ... }:
with lib;
let
common = config.selfhosted.common;
rootCfg = config.selfhosted.seafile;
cfg = rootCfg.server;
rootCfg = config.selfhosted;
common = rootCfg.common;
moduleCfg = rootCfg.seafile;
cfg = moduleCfg.server;
hostDataPath = "${common.dataDir}/seafile";
in
{
@@ -21,7 +22,7 @@ in
};
};
config = mkIf rootCfg.enable {
config = mkIf moduleCfg.enable {
virtualisation.oci-containers.containers.${cfg.name} = {
image = "docker.io/seafileltd/seafile-mc:13.0-latest";
ports = [
@@ -41,15 +42,15 @@ in
serviceConfig = {
Restart = lib.mkOverride 90 "always";
};
wantedBy = [ "${common.backend}-${rootCfg.targetName}.target" ];
partOf = [ "${common.backend}-${rootCfg.targetName}.target" ];
wantedBy = [ "${common.backend}-${moduleCfg.targetName}.target" ];
partOf = [ "${common.backend}-${moduleCfg.targetName}.target" ];
requires = [
"${common.backend}-${rootCfg.mariadb.name}.service"
"${common.backend}-${rootCfg.redis.name}.service"
"${common.backend}-${moduleCfg.mariadb.name}.service"
"${common.backend}-${moduleCfg.redis.name}.service"
];
after = [
"${common.backend}-${rootCfg.mariadb.name}.service"
"${common.backend}-${rootCfg.redis.name}.service"
"${common.backend}-${moduleCfg.mariadb.name}.service"
"${common.backend}-${moduleCfg.redis.name}.service"
];
preStart = ''
mkdir -p ${hostDataPath}/server/shared/seafile/conf
@@ -1,13 +1,13 @@
{ config, lib, ... }:
with lib;
let
rootCfg = config.selfhosted.seafile;
moduleCfg = config.selfhosted.seafile;
in
{
config = mkIf rootCfg.enable {
config = mkIf moduleCfg.enable {
sops.templates."seafile-thumbnail.env".content = ''
TIME_ZONE=${config.time.timeZone}
SEAFILE_MYSQL_DB_HOST=${rootCfg.mariadb.name}
SEAFILE_MYSQL_DB_HOST=${moduleCfg.mariadb.name}
SEAFILE_MYSQL_DB_PORT=3306
SEAFILE_MYSQL_DB_USER=seafile
SEAFILE_MYSQL_DB_PASSWORD=${config.sops.placeholder."seafile/mysql_password"}
@@ -17,7 +17,7 @@ in
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}
INNER_SEAHUB_SERVICE_URL=http://${moduleCfg.server.name}
THUMBNAIL_IMAGE_ORIGINAL_SIZE_LIMIT=256
SEAF_SERVER_STORAGE_TYPE=disk
'';
@@ -1,9 +1,10 @@
{ config, lib, ... }:
with lib;
let
common = config.selfhosted.common;
rootCfg = config.selfhosted.seafile;
cfg = rootCfg.thumbnail;
rootCfg = config.selfhosted;
common = rootCfg.common;
moduleCfg = rootCfg.seafile;
cfg = moduleCfg.thumbnail;
hostDataPath = "${common.dataDir}/seafile";
in
{
@@ -18,7 +19,7 @@ in
};
};
config = mkIf rootCfg.enable {
config = mkIf moduleCfg.enable {
virtualisation.oci-containers.containers.${cfg.name} = {
image = "docker.io/seafileltd/thumbnail-server:13.0.20";
ports = [
@@ -38,15 +39,15 @@ in
serviceConfig = {
Restart = lib.mkOverride 90 "always";
};
wantedBy = [ "${common.backend}-${rootCfg.targetName}.target" ];
partOf = [ "${common.backend}-${rootCfg.targetName}.target" ];
wantedBy = [ "${common.backend}-${moduleCfg.targetName}.target" ];
partOf = [ "${common.backend}-${moduleCfg.targetName}.target" ];
requires = [
"${common.backend}-${rootCfg.mariadb.name}.service"
"${common.backend}-${rootCfg.server.name}.service"
"${common.backend}-${moduleCfg.mariadb.name}.service"
"${common.backend}-${moduleCfg.server.name}.service"
];
after = [
"${common.backend}-${rootCfg.mariadb.name}.service"
"${common.backend}-${rootCfg.server.name}.service"
"${common.backend}-${moduleCfg.mariadb.name}.service"
"${common.backend}-${moduleCfg.server.name}.service"
];
};
};