From 4502e197bfbb63d1c5d7a0ab1d4cb0773db9c933 Mon Sep 17 00:00:00 2001 From: wi11-holdsworth <83637728+wi11-holdsworth@users.noreply.github.com> Date: Mon, 29 Dec 2025 14:00:36 +1100 Subject: [PATCH] refactor: store port as integer --- modules/nixos/features/copyparty.nix | 7 +++---- modules/nixos/features/couchdb.nix | 10 +++------- modules/nixos/features/flaresolverr.nix | 10 +++------- modules/nixos/features/homepage-dashboard.nix | 6 +++--- modules/nixos/features/immich.nix | 10 +++------- modules/nixos/features/jellyfin.nix | 4 ++-- modules/nixos/features/karakeep.nix | 6 +++--- modules/nixos/features/lidarr.nix | 12 +++++------- modules/nixos/features/miniflux.nix | 6 +++--- modules/nixos/features/ntfy-sh.nix | 6 +++--- modules/nixos/features/paperless.nix | 7 +++---- modules/nixos/features/prowlarr.nix | 15 +++++---------- modules/nixos/features/qbittorrent.nix | 10 +++------- modules/nixos/features/radarr.nix | 12 +++++------- modules/nixos/features/radicale.nix | 8 ++++---- modules/nixos/features/sonarr.nix | 12 +++++------- modules/nixos/features/syncthing.nix | 6 +++--- modules/nixos/features/vaultwarden.nix | 6 +++--- modules/templates/web-feature.nix | 4 ++-- 19 files changed, 64 insertions(+), 93 deletions(-) diff --git a/modules/nixos/features/copyparty.nix b/modules/nixos/features/copyparty.nix index a3b8114..560df1e 100644 --- a/modules/nixos/features/copyparty.nix +++ b/modules/nixos/features/copyparty.nix @@ -2,12 +2,11 @@ # keep-sorted start config, inputs, - lib, # keep-sorted end ... }: let - port = "5000"; + port = 5000; in { imports = [ inputs.copyparty.nixosModules.default ]; @@ -20,7 +19,7 @@ in e2dsa = true; e2ts = true; e2vu = true; - p = lib.toInt port; + p = port; }; accounts.will.passwordFile = config.age.secrets.copyparty-will.path; @@ -37,7 +36,7 @@ in nginx.virtualHosts."copyparty.fi33.buzz" = { forceSSL = true; useACMEHost = "fi33.buzz"; - locations."/".proxyPass = "http://localhost:${port}"; + locations."/".proxyPass = "http://localhost:${toString port}"; }; }; diff --git a/modules/nixos/features/couchdb.nix b/modules/nixos/features/couchdb.nix index 5b24367..d7656ee 100644 --- a/modules/nixos/features/couchdb.nix +++ b/modules/nixos/features/couchdb.nix @@ -1,9 +1,5 @@ -{ - lib, - ... -}: let - port = "5984"; + port = 5984; in { services = { @@ -12,7 +8,7 @@ in databaseDir = "/srv/couchdb"; viewIndexDir = "/srv/couchdb"; configFile = "/srv/couchdb"; - port = lib.toInt port; + inherit port; extraConfig = { chttpd = { require_valid_user = true; @@ -41,7 +37,7 @@ in nginx.virtualHosts."couchdb.fi33.buzz" = { forceSSL = true; useACMEHost = "fi33.buzz"; - locations."/".proxyPass = "http://localhost:${port}"; + locations."/".proxyPass = "http://localhost:${toString port}"; }; }; } diff --git a/modules/nixos/features/flaresolverr.nix b/modules/nixos/features/flaresolverr.nix index 86afdcd..e9f7f45 100644 --- a/modules/nixos/features/flaresolverr.nix +++ b/modules/nixos/features/flaresolverr.nix @@ -1,21 +1,17 @@ -{ - lib, - ... -}: let - port = "5011"; + port = 5011; in { services = { flaresolverr = { enable = true; - port = lib.toInt port; + inherit port; }; nginx.virtualHosts."flaresolverr.fi33.buzz" = { forceSSL = true; useACMEHost = "fi33.buzz"; - locations."/".proxyPass = "http://localhost:${port}"; + locations."/".proxyPass = "http://localhost:${toString port}"; }; }; } diff --git a/modules/nixos/features/homepage-dashboard.nix b/modules/nixos/features/homepage-dashboard.nix index c1eb3d1..df30830 100644 --- a/modules/nixos/features/homepage-dashboard.nix +++ b/modules/nixos/features/homepage-dashboard.nix @@ -7,7 +7,7 @@ ... }: let - port = "5004"; + port = 5004; genSecrets = secrets: lib.genAttrs secrets (secret: { @@ -38,7 +38,7 @@ in services = { homepage-dashboard = { enable = true; - listenPort = lib.toInt port; + listenPort = port; allowedHosts = "homepage-dashboard.fi33.buzz"; services = [ # keep-sorted start block=yes @@ -300,7 +300,7 @@ in nginx.virtualHosts."homepage-dashboard.fi33.buzz" = { forceSSL = true; useACMEHost = "fi33.buzz"; - locations."/".proxyPass = "http://localhost:${port}"; + locations."/".proxyPass = "http://localhost:${toString port}"; }; }; diff --git a/modules/nixos/features/immich.nix b/modules/nixos/features/immich.nix index 3d83d33..6a0abd4 100644 --- a/modules/nixos/features/immich.nix +++ b/modules/nixos/features/immich.nix @@ -1,15 +1,11 @@ -{ - lib, - ... -}: let - port = "2283"; + port = 2283; in { services = { immich = { enable = true; - port = lib.toInt "${port}"; + inherit port; mediaLocation = "/srv/immich"; }; @@ -28,7 +24,7 @@ in forceSSL = true; useACMEHost = "fi33.buzz"; locations."/" = { - proxyPass = "http://[::1]:${port}"; + proxyPass = "http://[::1]:${toString port}"; proxyWebsockets = true; }; }; diff --git a/modules/nixos/features/jellyfin.nix b/modules/nixos/features/jellyfin.nix index e64f6ad..330adff 100644 --- a/modules/nixos/features/jellyfin.nix +++ b/modules/nixos/features/jellyfin.nix @@ -1,5 +1,5 @@ let - port = "8096"; + port = 8096; in { services = { @@ -12,7 +12,7 @@ in nginx.virtualHosts."jellyfin.fi33.buzz" = { forceSSL = true; useACMEHost = "fi33.buzz"; - locations."/".proxyPass = "http://localhost:${port}"; + locations."/".proxyPass = "http://localhost:${toString port}"; }; }; diff --git a/modules/nixos/features/karakeep.nix b/modules/nixos/features/karakeep.nix index c113f66..09f8163 100644 --- a/modules/nixos/features/karakeep.nix +++ b/modules/nixos/features/karakeep.nix @@ -1,12 +1,12 @@ let - port = "5014"; + port = 5014; in { services = { karakeep = { enable = true; extraEnvironment = { - PORT = port; + PORT = toString port; DISABLE_NEW_RELEASE_CHECK = "true"; }; }; @@ -14,7 +14,7 @@ in nginx.virtualHosts."karakeep.fi33.buzz" = { forceSSL = true; useACMEHost = "fi33.buzz"; - locations."/".proxyPass = "http://localhost:${port}"; + locations."/".proxyPass = "http://localhost:${toString port}"; }; }; } diff --git a/modules/nixos/features/lidarr.nix b/modules/nixos/features/lidarr.nix index 39e6253..8132318 100644 --- a/modules/nixos/features/lidarr.nix +++ b/modules/nixos/features/lidarr.nix @@ -1,23 +1,21 @@ -{ - lib, - ... -}: let - port = "5012"; + port = 5012; in { services = { lidarr = { enable = true; dataDir = "/srv/lidarr"; - settings.server.port = lib.toInt port; + settings.server = { + inherit port; + }; group = "media"; }; nginx.virtualHosts."lidarr.fi33.buzz" = { forceSSL = true; useACMEHost = "fi33.buzz"; - locations."/".proxyPass = "http://localhost:${port}"; + locations."/".proxyPass = "http://localhost:${toString port}"; }; }; } diff --git a/modules/nixos/features/miniflux.nix b/modules/nixos/features/miniflux.nix index 7fd7403..10c4eeb 100644 --- a/modules/nixos/features/miniflux.nix +++ b/modules/nixos/features/miniflux.nix @@ -3,7 +3,7 @@ ... }: let - port = "5010"; + port = 5010; in { services = { @@ -12,7 +12,7 @@ in adminCredentialsFile = config.age.secrets.miniflux-creds.path; config = { BASE_URL = "https://miniflux.fi33.buzz"; - LISTEN_ADDR = "localhost:${port}"; + LISTEN_ADDR = "localhost:${toString port}"; }; }; @@ -28,7 +28,7 @@ in nginx.virtualHosts."miniflux.fi33.buzz" = { forceSSL = true; useACMEHost = "fi33.buzz"; - locations."/".proxyPass = "http://localhost:${port}"; + locations."/".proxyPass = "http://localhost:${toString port}"; }; }; diff --git a/modules/nixos/features/ntfy-sh.nix b/modules/nixos/features/ntfy-sh.nix index 681047f..d5a70e8 100644 --- a/modules/nixos/features/ntfy-sh.nix +++ b/modules/nixos/features/ntfy-sh.nix @@ -1,5 +1,5 @@ let - port = "5002"; + port = 5002; in { services = { @@ -7,7 +7,7 @@ in enable = true; settings = { base-url = "https://ntfy-sh.fi33.buzz"; - listen-http = ":${port}"; + listen-http = ":${toString port}"; behind-proxy = true; }; }; @@ -16,7 +16,7 @@ in forceSSL = true; useACMEHost = "fi33.buzz"; locations."/" = { - proxyPass = "http://localhost:${port}"; + proxyPass = "http://localhost:${toString port}"; proxyWebsockets = true; }; }; diff --git a/modules/nixos/features/paperless.nix b/modules/nixos/features/paperless.nix index 348b42d..6b61e35 100644 --- a/modules/nixos/features/paperless.nix +++ b/modules/nixos/features/paperless.nix @@ -1,10 +1,9 @@ { config, - lib, ... }: let - port = "5013"; + port = 5013; in { services = { @@ -13,7 +12,7 @@ in dataDir = "/srv/paperless"; database.createLocally = true; passwordFile = config.age.secrets.paperless.path; - port = lib.toInt port; + inherit port; settings = { PAPERLESS_URL = "https://paperless.fi33.buzz"; }; @@ -33,7 +32,7 @@ in nginx.virtualHosts."paperless.fi33.buzz" = { forceSSL = true; useACMEHost = "fi33.buzz"; - locations."/".proxyPass = "http://localhost:${port}"; + locations."/".proxyPass = "http://localhost:${toString port}"; }; }; diff --git a/modules/nixos/features/prowlarr.nix b/modules/nixos/features/prowlarr.nix index 2e439b5..9fbb8e6 100644 --- a/modules/nixos/features/prowlarr.nix +++ b/modules/nixos/features/prowlarr.nix @@ -1,26 +1,21 @@ -{ - lib, - ... -}: let - port = "5009"; + port = 5009; in { services = { prowlarr = { enable = true; dataDir = "/srv/prowlarr"; - settings.server.port = lib.toInt port; + settings.server = { + inherit port; + }; }; nginx = { virtualHosts."prowlarr.fi33.buzz" = { forceSSL = true; useACMEHost = "fi33.buzz"; - locations."/" = { - proxyPass = "http://localhost:${port}"; - # proxyWebsockets = true; - }; + locations."/".proxyPass = "http://localhost:${toString port}"; }; }; }; diff --git a/modules/nixos/features/qbittorrent.nix b/modules/nixos/features/qbittorrent.nix index b67b01e..0134eb1 100644 --- a/modules/nixos/features/qbittorrent.nix +++ b/modules/nixos/features/qbittorrent.nix @@ -1,15 +1,11 @@ -{ - lib, - ... -}: let - port = "5005"; + port = 5005; in { services = { qbittorrent = { enable = true; - webuiPort = lib.toInt port; + webuiPort = port; profileDir = "/srv"; group = "media"; extraArgs = [ @@ -20,7 +16,7 @@ in nginx.virtualHosts."qbittorrent.fi33.buzz" = { forceSSL = true; useACMEHost = "fi33.buzz"; - locations."/".proxyPass = "http://localhost:${port}"; + locations."/".proxyPass = "http://localhost:${toString port}"; }; }; diff --git a/modules/nixos/features/radarr.nix b/modules/nixos/features/radarr.nix index 51aeef1..8cce599 100644 --- a/modules/nixos/features/radarr.nix +++ b/modules/nixos/features/radarr.nix @@ -1,23 +1,21 @@ -{ - lib, - ... -}: let - port = "5007"; + port = 5007; in { services = { radarr = { enable = true; dataDir = "/srv/radarr"; - settings.server.port = lib.toInt port; + settings.server = { + inherit port; + }; group = "media"; }; nginx.virtualHosts."radarr.fi33.buzz" = { forceSSL = true; useACMEHost = "fi33.buzz"; - locations."/".proxyPass = "http://localhost:${port}"; + locations."/".proxyPass = "http://localhost:${toString port}"; }; }; } diff --git a/modules/nixos/features/radicale.nix b/modules/nixos/features/radicale.nix index 1e0b722..6ced520 100644 --- a/modules/nixos/features/radicale.nix +++ b/modules/nixos/features/radicale.nix @@ -3,7 +3,7 @@ ... }: let - port = "5003"; + port = 5003; in { services = { @@ -12,8 +12,8 @@ in settings = { server = { hosts = [ - "0.0.0.0:${port}" - "[::]:${port}" + "0.0.0.0:${toString port}" + "[::]:${toString port}" ]; }; auth = { @@ -30,7 +30,7 @@ in nginx.virtualHosts."radicale.fi33.buzz" = { forceSSL = true; useACMEHost = "fi33.buzz"; - locations."/".proxyPass = "http://localhost:${port}"; + locations."/".proxyPass = "http://localhost:${toString port}"; }; }; diff --git a/modules/nixos/features/sonarr.nix b/modules/nixos/features/sonarr.nix index 95ac80e..f5ff5b3 100644 --- a/modules/nixos/features/sonarr.nix +++ b/modules/nixos/features/sonarr.nix @@ -1,23 +1,21 @@ -{ - lib, - ... -}: let - port = "5006"; + port = 5006; in { services = { sonarr = { enable = true; dataDir = "/srv/sonarr"; - settings.server.port = lib.toInt port; + settings.server = { + inherit port; + }; group = "media"; }; nginx.virtualHosts."sonarr.fi33.buzz" = { forceSSL = true; useACMEHost = "fi33.buzz"; - locations."/".proxyPass = "http://localhost:${port}"; + locations."/".proxyPass = "http://localhost:${toString port}"; }; }; } diff --git a/modules/nixos/features/syncthing.nix b/modules/nixos/features/syncthing.nix index 47e804c..513b467 100644 --- a/modules/nixos/features/syncthing.nix +++ b/modules/nixos/features/syncthing.nix @@ -4,7 +4,7 @@ ... }: let - port = "5008"; + port = 5008; devicesList = [ # keep-sorted start block=yes { @@ -45,7 +45,7 @@ in services = { syncthing = { enable = true; - guiAddress = "0.0.0.0:${port}"; + guiAddress = "0.0.0.0:${toString port}"; openDefaultPorts = true; user = "${userName}"; dataDir = "/home/${userName}"; @@ -69,7 +69,7 @@ in nginx.virtualHosts."syncthing.fi33.buzz" = { forceSSL = true; useACMEHost = "fi33.buzz"; - locations."/".proxyPass = "http://localhost:${port}"; + locations."/".proxyPass = "http://localhost:${toString port}"; }; }; } diff --git a/modules/nixos/features/vaultwarden.nix b/modules/nixos/features/vaultwarden.nix index c4e069d..2ffb556 100644 --- a/modules/nixos/features/vaultwarden.nix +++ b/modules/nixos/features/vaultwarden.nix @@ -3,7 +3,7 @@ ... }: let - port = "5001"; + port = 5001; in { services = { @@ -11,7 +11,7 @@ in enable = true; backupDir = "/srv/vaultwarden"; config = { - rocketPort = "${port}"; + rocketPort = toString port; domain = "https://vaultwarden.fi33.buzz"; signupsAllowed = false; invitationsAllowed = false; @@ -26,7 +26,7 @@ in forceSSL = true; useACMEHost = "fi33.buzz"; locations."/" = { - proxyPass = "http://localhost:${port}"; + proxyPass = "http://localhost:${toString port}"; proxyWebsockets = true; }; }; diff --git a/modules/templates/web-feature.nix b/modules/templates/web-feature.nix index 98eba78..ab1b9f0 100644 --- a/modules/templates/web-feature.nix +++ b/modules/templates/web-feature.nix @@ -1,5 +1,5 @@ let - port = "port"; + port = 0000; in { services = { @@ -12,7 +12,7 @@ in nginx.virtualHosts."feature.fi33.buzz" = { forceSSL = true; useACMEHost = "fi33.buzz"; - locations."/".proxyPass = "http://localhost:${port}"; + locations."/".proxyPass = "http://localhost:${toString port}"; }; }; }