refactor(services): standardize service module options

This commit is contained in:
tux
2026-08-07 04:56:47 +05:30
parent 82493de787
commit 7f43037522
4 changed files with 32 additions and 42 deletions

View File

@@ -47,12 +47,7 @@
mediaflow-proxy = { mediaflow-proxy = {
enable = true; enable = true;
port = 8888; port = 8888;
domain = "mf-proxy.lab.tux.rs";
environment = {
APP__SERVER__HOST = "0.0.0.0";
APP__SERVER__PORT = "8888";
};
environmentFile = innerArgs.config.sops.secrets."mediaflow-proxy".path; environmentFile = innerArgs.config.sops.secrets."mediaflow-proxy".path;
}; };

View File

@@ -18,17 +18,17 @@
default = 3000; default = 3000;
}; };
domain = mkOption {
type = types.str;
default = "";
};
dataDir = mkOption { dataDir = mkOption {
type = types.path; type = types.path;
default = "/var/lib/docker/volumes/aiostreams/_data"; default = "/var/lib/docker/volumes/aiostreams/_data";
description = "Directory to store persistent AIOStreams data"; description = "Directory to store persistent AIOStreams data";
}; };
environment = mkOption {
type = with types; attrsOf str;
default = { };
};
environmentFile = mkOption { environmentFile = mkOption {
type = with types; path; type = with types; path;
default = ""; default = "";
@@ -42,25 +42,23 @@
ports = [ ports = [
"${toString cfg.port}:3000" "${toString cfg.port}:3000"
]; ];
environment = {
environment = cfg.environment; ADDON_ID = "${cfg.domain}";
BASE_URL = "https://${cfg.domain}";
};
environmentFiles = [ cfg.environmentFile ]; environmentFiles = [ cfg.environmentFile ];
volumes = [ volumes = [
"${cfg.dataDir}:/app/data" "${cfg.dataDir}:/app/data"
]; ];
}; };
services.nginx.virtualHosts = { services.nginx.virtualHosts.${cfg.domain} = {
"${cfg.environment.ADDON_ID}" = {
forceSSL = true; forceSSL = true;
useACMEHost = "lab.tux.rs"; useACMEHost = config.tnix.services.nginx.domain;
locations = { locations."/" = {
"/" = {
proxyPass = "http://localhost:${toString cfg.port}"; proxyPass = "http://localhost:${toString cfg.port}";
}; };
}; };
}; };
}; };
};
};
} }

View File

@@ -18,9 +18,9 @@
default = 8888; default = 8888;
}; };
environment = mkOption { domain = mkOption {
type = with types; attrsOf str; type = types.str;
default = { }; default = "";
}; };
environmentFile = mkOption { environmentFile = mkOption {
@@ -36,20 +36,19 @@
ports = [ ports = [
"${toString cfg.port}:8888" "${toString cfg.port}:8888"
]; ];
environment = {
environment = cfg.environment; APP__SERVER__HOST = "0.0.0.0";
APP__SERVER__PORT = "${toString cfg.port}";
};
environmentFiles = [ cfg.environmentFile ]; environmentFiles = [ cfg.environmentFile ];
}; };
services.nginx.virtualHosts = { services.nginx.virtualHosts.${cfg.domain} = {
"mf-proxy.lab.tux.rs" = {
forceSSL = true; forceSSL = true;
useACMEHost = "lab.tux.rs"; useACMEHost = config.tnix.services.nginx.domain;
locations = { locations."/" = {
"/" = {
proxyPass = "http://localhost:${toString cfg.port}"; proxyPass = "http://localhost:${toString cfg.port}";
}; proxyWebsockets = true;
};
}; };
}; };
}; };

View File

@@ -43,14 +43,12 @@
nginx.virtualHosts.${cfg.domain} = { nginx.virtualHosts.${cfg.domain} = {
forceSSL = true; forceSSL = true;
useACMEHost = "lab.tux.rs"; useACMEHost = config.tnix.services.nginx.domain;
locations = { locations."/" = {
"/" = {
proxyPass = "http://localhost:${toString cfg.port}"; proxyPass = "http://localhost:${toString cfg.port}";
proxyWebsockets = true; proxyWebsockets = true;
}; };
}; };
};
postgresql = { postgresql = {
enable = true; enable = true;