From 7f4303752242e25b4b79f77119dfb25d6ad4a17c Mon Sep 17 00:00:00 2001 From: tux Date: Fri, 7 Aug 2026 04:56:47 +0530 Subject: [PATCH] refactor(services): standardize service module options --- modules/hosts/alpha/config.nix | 7 +---- modules/nixos/services/aiostreams.nix | 30 ++++++++++------------ modules/nixos/services/mediaflow-proxy.nix | 27 ++++++++++--------- modules/nixos/services/vaultwarden.nix | 10 +++----- 4 files changed, 32 insertions(+), 42 deletions(-) diff --git a/modules/hosts/alpha/config.nix b/modules/hosts/alpha/config.nix index ee05a95..b20909f 100644 --- a/modules/hosts/alpha/config.nix +++ b/modules/hosts/alpha/config.nix @@ -47,12 +47,7 @@ mediaflow-proxy = { enable = true; port = 8888; - - environment = { - APP__SERVER__HOST = "0.0.0.0"; - APP__SERVER__PORT = "8888"; - }; - + domain = "mf-proxy.lab.tux.rs"; environmentFile = innerArgs.config.sops.secrets."mediaflow-proxy".path; }; diff --git a/modules/nixos/services/aiostreams.nix b/modules/nixos/services/aiostreams.nix index 6f4b25e..6fb9ae8 100644 --- a/modules/nixos/services/aiostreams.nix +++ b/modules/nixos/services/aiostreams.nix @@ -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}"; }; }; }; diff --git a/modules/nixos/services/mediaflow-proxy.nix b/modules/nixos/services/mediaflow-proxy.nix index b14bb93..dc1ba5f 100644 --- a/modules/nixos/services/mediaflow-proxy.nix +++ b/modules/nixos/services/mediaflow-proxy.nix @@ -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; }; }; }; diff --git a/modules/nixos/services/vaultwarden.nix b/modules/nixos/services/vaultwarden.nix index 116194d..be96151 100644 --- a/modules/nixos/services/vaultwarden.nix +++ b/modules/nixos/services/vaultwarden.nix @@ -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; }; };