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

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

View File

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

View File

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