treewide: remove duplicate port settings

This commit is contained in:
Felix Buehler 2025-02-25 23:53:44 +01:00
parent 375424cb9f
commit b6b9972d60
21 changed files with 58 additions and 143 deletions

View file

@ -12,12 +12,6 @@ in
{ {
options.my.services.alertmanager = with lib; { options.my.services.alertmanager = with lib; {
enable = mkEnableOption "Prometheus alertmanager for monitoring"; enable = mkEnableOption "Prometheus alertmanager for monitoring";
port = mkOption {
type = types.port;
default = 9093;
example = 3002;
description = "Internal alertmanager port";
};
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
@ -34,20 +28,27 @@ in
prometheus = { prometheus = {
alertmanager = { alertmanager = {
enable = true; enable = true;
inherit (cfg) port;
configuration = import ./config.nix; configuration = import ./config.nix;
webExternalUrl = "https://alerts.${domain}"; webExternalUrl = "https://alerts.${domain}";
# fix issue: https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/4556 # fix issue: https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/4556
extraFlags = [ "--cluster.advertise-address 127.0.0.1:${toString cfg.port}" ]; extraFlags = [
"--cluster.advertise-address 127.0.0.1:${toString config.services.prometheus.alertmanager.port}"
];
}; };
alertmanagers = [ { static_configs = [ { targets = [ "localhost:${toString cfg.port}" ]; } ]; } ]; alertmanagers = [
{
static_configs = [
{ targets = [ "localhost:${toString config.services.prometheus.alertmanager.port}" ]; }
];
}
];
scrapeConfigs = [ scrapeConfigs = [
{ {
job_name = "alertmanager"; job_name = "alertmanager";
static_configs = [ static_configs = [
{ {
targets = [ "localhost:${toString cfg.port}" ]; targets = [ "localhost:${toString config.services.prometheus.alertmanager.port}" ];
labels = { labels = {
instance = config.networking.hostName; instance = config.networking.hostName;
}; };
@ -62,7 +63,7 @@ in
{ {
name = "Alertmanager"; name = "Alertmanager";
type = "alertmanager"; type = "alertmanager";
url = "http://localhost:${toString cfg.port}"; url = "http://localhost:${toString config.services.prometheus.alertmanager.port}";
jsonData = { jsonData = {
implementation = "prometheus"; implementation = "prometheus";
handleGrafanaManagedAlerts = config.services.prometheus.enable; handleGrafanaManagedAlerts = config.services.prometheus.enable;
@ -135,7 +136,7 @@ in
my.services.webserver.virtualHosts = [ my.services.webserver.virtualHosts = [
{ {
subdomain = "alerts"; subdomain = "alerts";
inherit (cfg) port; inherit (config.services.prometheus.alertmanager) port;
} }
]; ];

View file

@ -3,7 +3,7 @@
let let
cfg = config.my.services.bazarr; cfg = config.my.services.bazarr;
inherit (config.networking) domain; inherit (config.networking) domain;
port = 6767; port = config.services.bazarr.listenPort;
in in
{ {
options.my.services.bazarr = with lib; { options.my.services.bazarr = with lib; {

View file

@ -10,12 +10,6 @@ in
{ {
options.my.services.fritzbox = with lib; { options.my.services.fritzbox = with lib; {
enable = mkEnableOption "Fritzbox-Monitoring"; enable = mkEnableOption "Fritzbox-Monitoring";
port = mkOption {
type = types.port;
default = 9787;
example = 8080;
description = "Internal port";
};
username = mkOption { username = mkOption {
type = types.str; type = types.str;
@ -34,7 +28,7 @@ in
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
services = { services = {
prometheus.exporters.fritz = { prometheus.exporters.fritz = {
inherit (cfg) enable port; inherit (cfg) enable;
settings.devices = [ settings.devices = [
{ {
inherit (cfg) username; inherit (cfg) username;
@ -48,7 +42,7 @@ in
job_name = "fritzbox"; job_name = "fritzbox";
static_configs = [ static_configs = [
{ {
targets = [ "localhost:${toString cfg.port}" ]; targets = [ "localhost:${toString config.services.prometheus.exporters.fritzbox.port}" ];
labels = { labels = {
instance = config.networking.hostName; instance = config.networking.hostName;
}; };

View file

@ -12,12 +12,6 @@ in
{ {
options.my.services.gitea = with lib; { options.my.services.gitea = with lib; {
enable = mkEnableOption "Gitea"; enable = mkEnableOption "Gitea";
port = mkOption {
type = types.port;
default = 3042;
example = 8080;
description = "Internal port";
};
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
@ -26,7 +20,7 @@ in
enable = true; enable = true;
settings = { settings = {
server = { server = {
HTTP_PORT = cfg.port; HTTP_PORT = 3042;
ROOT_URL = "https://code.${domain}"; ROOT_URL = "https://code.${domain}";
}; };
session.COOKIE_SECURE = true; session.COOKIE_SECURE = true;
@ -44,7 +38,7 @@ in
job_name = "gitea"; job_name = "gitea";
static_configs = [ static_configs = [
{ {
targets = [ "localhost:${toString cfg.port}" ]; targets = [ "localhost:${toString config.services.gitea.settings.server.HTTP_PORT}" ];
labels = { labels = {
instance = config.networking.hostName; instance = config.networking.hostName;
}; };
@ -69,7 +63,7 @@ in
webserver.virtualHosts = [ webserver.virtualHosts = [
{ {
subdomain = "code"; subdomain = "code";
inherit (cfg) port; port = config.services.gitea.settings.server.HTTP_PORT;
} }
]; ];

View file

@ -13,13 +13,6 @@ in
options.my.services.grafana = with lib; { options.my.services.grafana = with lib; {
enable = mkEnableOption "Grafana for visualizing"; enable = mkEnableOption "Grafana for visualizing";
port = mkOption {
type = types.port;
default = 9500;
example = 3001;
description = "Internal port";
};
username = mkOption { username = mkOption {
type = types.str; type = types.str;
default = "felix"; default = "felix";
@ -42,7 +35,6 @@ in
server = { server = {
domain = "visualization.${domain}"; domain = "visualization.${domain}";
root_url = "https://visualization.${domain}/"; root_url = "https://visualization.${domain}/";
http_port = cfg.port;
}; };
security = { security = {
@ -69,7 +61,7 @@ in
job_name = "grafana"; job_name = "grafana";
static_configs = [ static_configs = [
{ {
targets = [ "localhost:${toString cfg.port}" ]; targets = [ "localhost:${toString config.services.grafana.settings.server.http_port}" ];
labels = { labels = {
instance = config.networking.hostName; instance = config.networking.hostName;
}; };
@ -82,7 +74,7 @@ in
my.services.webserver.virtualHosts = [ my.services.webserver.virtualHosts = [
{ {
subdomain = "visualization"; subdomain = "visualization";
inherit (cfg) port; port = config.services.grafana.settings.server.http_port;
} }
]; ];

View file

@ -26,13 +26,6 @@ in
Additional settings. Additional settings.
''; '';
}; };
port = mkOption {
type = types.port;
default = 3080;
example = 8080;
description = "Internal port for webui";
};
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
@ -42,7 +35,7 @@ in
settings = { settings = {
domain = "notes.${domain}"; domain = "notes.${domain}";
inherit (cfg) port; port = 3080;
protocolUseSSL = true; protocolUseSSL = true;
db = { db = {
dialect = "sqlite"; dialect = "sqlite";
@ -57,7 +50,7 @@ in
job_name = "hedgedoc"; job_name = "hedgedoc";
static_configs = [ static_configs = [
{ {
targets = [ "localhost:${toString cfg.port}" ]; targets = [ "localhost:${toString config.services.hedgedoc.settings.port}" ];
labels = { labels = {
instance = config.networking.hostName; instance = config.networking.hostName;
}; };
@ -79,7 +72,7 @@ in
my.services.webserver.virtualHosts = [ my.services.webserver.virtualHosts = [
{ {
subdomain = "notes"; subdomain = "notes";
inherit (cfg) port; inherit (config.services.hedgedoc.settings) port;
} }
]; ];

View file

@ -15,14 +15,6 @@ in
package = lib.mkPackageOption pkgs "home-assistant" { }; package = lib.mkPackageOption pkgs "home-assistant" { };
port = lib.mkOption {
type = lib.types.port;
default = 8123;
description = ''
Web interface port.
'';
};
extraComponents = mkOption { extraComponents = mkOption {
type = types.listOf (types.enum cfg.package.availableComponents); type = types.listOf (types.enum cfg.package.availableComponents);
example = literalExpression '' example = literalExpression ''
@ -99,10 +91,9 @@ in
unit_system = "metric"; unit_system = "metric";
time_zone = cfg.timezone; time_zone = cfg.timezone;
external_url = "https://automation.${domain}"; external_url = "https://automation.${domain}";
internal_url = "http://localhost:${toString cfg.port}"; internal_url = "http://localhost:${toString config.services.home-assistant.config.http.server_port}";
}; };
http = { http = {
server_port = cfg.port;
use_x_forwarded_for = true; use_x_forwarded_for = true;
trusted_proxies = [ trusted_proxies = [
"127.0.0.1" "127.0.0.1"
@ -126,7 +117,7 @@ in
metrics_path = "/api/prometheus"; metrics_path = "/api/prometheus";
static_configs = [ static_configs = [
{ {
targets = [ "localhost:${toString cfg.port}" ]; targets = [ "localhost:${toString config.services.home-assistant.config.http.server_port}" ];
labels = { labels = {
instance = config.networking.hostName; instance = config.networking.hostName;
}; };
@ -148,7 +139,7 @@ in
my.services.webserver.virtualHosts = [ my.services.webserver.virtualHosts = [
{ {
subdomain = "automation"; subdomain = "automation";
inherit (cfg) port; port = config.services.home-assistant.config.http.server_port;
} }
{ {
subdomain = "esphome"; subdomain = "esphome";

View file

@ -8,7 +8,6 @@
let let
cfg = config.my.services.jellyfin; cfg = config.my.services.jellyfin;
inherit (config.networking) domain; inherit (config.networking) domain;
port = 8096;
# enable monitoring # enable monitoring
jellyfin-with-metrics = pkgs.jellyfin.overrideAttrs (attrs: { jellyfin-with-metrics = pkgs.jellyfin.overrideAttrs (attrs: {
patches = patches =
@ -50,7 +49,8 @@ in
my.services.webserver.virtualHosts = [ my.services.webserver.virtualHosts = [
{ {
subdomain = "media"; subdomain = "media";
inherit port; # jellyfin does not allow modification
port = 8096;
} }
]; ];

View file

@ -7,18 +7,13 @@
}: }:
let let
cfg = config.my.services.loki; cfg = config.my.services.loki;
# no default port defined in nixpkgs
port = 3101;
in in
{ {
options.my.services.loki = with lib; { options.my.services.loki = with lib; {
enable = mkEnableOption "loki log monitoring"; enable = mkEnableOption "loki log monitoring";
port = mkOption {
type = types.port;
default = 3100;
example = 3002;
description = "Internal port";
};
rules = mkOption { rules = mkOption {
type = types.attrsOf ( type = types.attrsOf (
types.submodule { types.submodule {
@ -91,7 +86,7 @@ in
configuration = { configuration = {
server = { server = {
http_listen_address = "localhost"; http_listen_address = "localhost";
http_listen_port = cfg.port; http_listen_port = port;
}; };
auth_enabled = false; auth_enabled = false;
@ -113,7 +108,7 @@ in
local.directory = "${config.services.loki.dataDir}/ruler"; local.directory = "${config.services.loki.dataDir}/ruler";
}; };
rule_path = "${config.services.loki.dataDir}/rules"; rule_path = "${config.services.loki.dataDir}/rules";
alertmanager_url = "http://localhost:${toString config.my.services.alertmanager.port}"; alertmanager_url = "http://localhost:${toString config.services.prometheus.alertmanager.port}";
enable_alertmanager_v2 = true; enable_alertmanager_v2 = true;
}; };
@ -151,7 +146,7 @@ in
name = "Loki"; name = "Loki";
type = "loki"; type = "loki";
access = "proxy"; access = "proxy";
url = "http://localhost:${toString cfg.port}"; url = "http://localhost:${toString port}";
} }
]; ];
dashboards.settings.providers = [ dashboards.settings.providers = [
@ -169,7 +164,7 @@ in
job_name = "loki"; job_name = "loki";
static_configs = [ static_configs = [
{ {
targets = [ "localhost:${toString cfg.port}" ]; targets = [ "localhost:${toString port}" ];
labels = { labels = {
instance = config.networking.hostName; instance = config.networking.hostName;
}; };

View file

@ -29,13 +29,6 @@ in
''; '';
}; };
port = mkOption {
type = types.port;
default = 4533;
example = 8080;
description = "Internal port for webui";
};
musicFolder = mkOption { musicFolder = mkOption {
type = types.str; type = types.str;
example = "/mnt/music/"; example = "/mnt/music/";
@ -49,7 +42,6 @@ in
enable = true; enable = true;
settings = cfg.settings // { settings = cfg.settings // {
Port = cfg.port;
MusicFolder = cfg.musicFolder; MusicFolder = cfg.musicFolder;
LogLevel = "info"; LogLevel = "info";
Prometheus.Enabled = config.services.prometheus.enable; Prometheus.Enabled = config.services.prometheus.enable;
@ -62,7 +54,7 @@ in
job_name = "navidrome"; job_name = "navidrome";
static_configs = [ static_configs = [
{ {
targets = [ "localhost:${toString cfg.port}" ]; targets = [ "localhost:${toString config.services.navidrome.settings.Port}" ];
labels = { labels = {
instance = config.networking.hostName; instance = config.networking.hostName;
}; };
@ -92,7 +84,7 @@ in
my.services.webserver.virtualHosts = [ my.services.webserver.virtualHosts = [
{ {
subdomain = "music"; subdomain = "music";
inherit (cfg) port; port = config.services.navidrome.settings.Port;
} }
]; ];

View file

@ -47,12 +47,6 @@ in
'nextcloud' user. 'nextcloud' user.
''; '';
}; };
exporterPort = mkOption {
type = types.port;
default = 9205;
example = 8080;
description = "Internal port for the exporter";
};
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
@ -102,7 +96,6 @@ in
url = "https://cloud.${domain}"; url = "https://cloud.${domain}";
username = cfg.admin; username = cfg.admin;
passwordFile = cfg.exporterPasswordFile; passwordFile = cfg.exporterPasswordFile;
port = cfg.exporterPort;
}; };
prometheus.scrapeConfigs = [ prometheus.scrapeConfigs = [
@ -110,7 +103,7 @@ in
job_name = "nextcloud"; job_name = "nextcloud";
static_configs = [ static_configs = [
{ {
targets = [ "localhost:${toString cfg.exporterPort}" ]; targets = [ "localhost:${toString config.services.prometheus.exporters.nextcloud.port}" ];
labels = { labels = {
instance = config.networking.hostName; instance = config.networking.hostName;
}; };

View file

@ -24,7 +24,6 @@ in
"textfile" "textfile"
]; ];
extraFlags = [ "--collector.textfile.directory=/etc/prometheus-node-exporter-text-files" ]; extraFlags = [ "--collector.textfile.directory=/etc/prometheus-node-exporter-text-files" ];
port = 9100;
}; };
systemd = { systemd = {
enable = true; enable = true;

View file

@ -14,17 +14,10 @@ in
example = "/run/secrets/freshrss"; example = "/run/secrets/freshrss";
}; };
port = mkOption {
type = types.port;
default = 28981;
example = 8080;
description = "Internal port for webui";
};
mediaDir = mkOption { mediaDir = mkOption {
type = types.path; type = types.path;
description = "Location of the FreshRSS data."; description = "Location of the FreshRSS data.";
example = "/run/secrets/freshrss"; example = "/data/docs";
}; };
settings = mkOption { settings = mkOption {
@ -37,7 +30,7 @@ in
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
services.paperless = { services.paperless = {
enable = true; enable = true;
inherit (cfg) port mediaDir passwordFile; inherit (cfg) mediaDir passwordFile;
settings = { settings = {
PAPERLESS_OCR_LANGUAGE = "deu+eng"; PAPERLESS_OCR_LANGUAGE = "deu+eng";
} // cfg.settings; } // cfg.settings;
@ -48,7 +41,7 @@ in
my.services.webserver.virtualHosts = [ my.services.webserver.virtualHosts = [
{ {
subdomain = "docs"; subdomain = "docs";
inherit (cfg) port; inherit (config.services.paperless) port;
} }
]; ];

View file

@ -6,7 +6,7 @@ let
in in
{ {
options.my.services.passworts = with lib; { options.my.services.passworts = with lib; {
enable = mkEnableOption "Navidrome Music Server"; enable = mkEnableOption "Passwords Server";
port = mkOption { port = mkOption {
type = types.port; type = types.port;
default = 5010; default = 5010;

View file

@ -3,6 +3,7 @@
let let
cfg = config.my.services.photos; cfg = config.my.services.photos;
inherit (config.networking) domain; inherit (config.networking) domain;
inherit (config.services.immich) port;
in in
{ {
options.my.services.photos = { options.my.services.photos = {
@ -16,14 +17,6 @@ in
''; '';
}; };
port = lib.mkOption {
type = lib.types.port;
default = 2283;
description = ''
Web interface port.
'';
};
settings = lib.mkOption { settings = lib.mkOption {
type = lib.types.anything; type = lib.types.anything;
default = { }; default = { };
@ -46,18 +39,15 @@ in
services.immich = { services.immich = {
enable = true; enable = true;
# mediaLocation = path; # mediaLocation = path;
inherit (cfg) inherit (cfg) secretsFile;
secretsFile
port
;
settings = { settings = {
ffmpeg.transcode = "disabled"; ffmpeg.transcode = "disabled";
server.externalDomain = "https://photos.${domain}"; server.externalDomain = "https://photos.${domain}";
} // cfg.settings; } // cfg.settings;
environment = { environment = {
IMMICH_TELEMETRY_INCLUDE = "all"; IMMICH_TELEMETRY_INCLUDE = "all";
IMMICH_API_METRICS_PORT = toString (cfg.port + 1); IMMICH_API_METRICS_PORT = toString (port + 1);
IMMICH_MICROSERVICES_METRICS_PORT = toString (cfg.port + 2); IMMICH_MICROSERVICES_METRICS_PORT = toString (port + 2);
}; };
}; };
@ -67,14 +57,14 @@ in
job_name = "immich"; job_name = "immich";
static_configs = [ static_configs = [
{ {
targets = [ "localhost:${toString (cfg.port + 1)}" ]; targets = [ "localhost:${toString (port + 1)}" ];
labels = { labels = {
instance = config.networking.hostName; instance = config.networking.hostName;
service = "api"; service = "api";
}; };
} }
{ {
targets = [ "localhost:${toString (cfg.port + 2)}" ]; targets = [ "localhost:${toString (port + 2)}" ];
labels = { labels = {
instance = config.networking.hostName; instance = config.networking.hostName;
service = "server"; service = "server";
@ -88,7 +78,7 @@ in
my.services.webserver.virtualHosts = [ my.services.webserver.virtualHosts = [
{ {
subdomain = "photos"; subdomain = "photos";
inherit (cfg) port; inherit port;
} }
]; ];

View file

@ -13,13 +13,6 @@ in
options.my.services.prometheus = with lib; { options.my.services.prometheus = with lib; {
enable = mkEnableOption "Prometheus for monitoring"; enable = mkEnableOption "Prometheus for monitoring";
port = mkOption {
type = types.port;
default = 9090;
example = 3002;
description = "Internal prometheus port";
};
scrapeInterval = mkOption { scrapeInterval = mkOption {
type = types.str; type = types.str;
default = "15s"; default = "15s";
@ -88,7 +81,6 @@ in
prometheus = { prometheus = {
enable = true; enable = true;
webExternalUrl = "https://monitor.${domain}"; webExternalUrl = "https://monitor.${domain}";
inherit (cfg) port;
inherit (cfg) retentionTime; inherit (cfg) retentionTime;
@ -123,7 +115,7 @@ in
job_name = "prometheus"; job_name = "prometheus";
static_configs = [ static_configs = [
{ {
targets = [ "localhost:${toString cfg.port}" ]; targets = [ "localhost:${toString config.services.prometheus.port}" ];
labels = { labels = {
instance = config.networking.hostName; instance = config.networking.hostName;
}; };
@ -191,7 +183,7 @@ in
webserver.virtualHosts = [ webserver.virtualHosts = [
{ {
subdomain = "monitor"; subdomain = "monitor";
inherit (cfg) port; inherit (config.services.prometheus) port;
} }
]; ];

View file

@ -3,6 +3,7 @@
let let
cfg = config.my.services.prowlarr; cfg = config.my.services.prowlarr;
inherit (config.networking) domain; inherit (config.networking) domain;
# in 25.05 this might be configurable
port = 9696; port = 9696;
in in
{ {

View file

@ -3,6 +3,7 @@
let let
cfg = config.my.services.radarr; cfg = config.my.services.radarr;
inherit (config.networking) domain; inherit (config.networking) domain;
# in 25.05 this might be configurable
port = 7878; port = 7878;
in in
{ {

View file

@ -3,6 +3,7 @@
let let
cfg = config.my.services.sonarr; cfg = config.my.services.sonarr;
inherit (config.networking) domain; inherit (config.networking) domain;
# in 25.05 this might be configurable
port = 8989; port = 8989;
in in
{ {

View file

@ -7,25 +7,18 @@ in
{ {
options.my.services.tandoor-recipes = with lib; { options.my.services.tandoor-recipes = with lib; {
enable = mkEnableOption "Tandoor Recipes"; enable = mkEnableOption "Tandoor Recipes";
port = mkOption {
type = types.port;
default = 8089;
example = 8080;
description = "Internal port";
};
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
services.tandoor-recipes = { services.tandoor-recipes = {
enable = true; enable = true;
inherit (cfg) port;
}; };
# Proxy to Tandoor-Recipes # Proxy to Tandoor-Recipes
my.services.webserver.virtualHosts = [ my.services.webserver.virtualHosts = [
{ {
subdomain = "recipes"; subdomain = "recipes";
inherit (cfg) port; inherit (config.services.tandoor-recipes) port;
} }
]; ];

View file

@ -10,7 +10,7 @@ in
isMaster = mkEnableOption "Headscale Master"; isMaster = mkEnableOption "Headscale Master";
port = mkOption { port = mkOption {
type = types.port; type = types.port;
default = 8099; default = 8090;
example = 8080; example = 8080;
description = "Internal port"; description = "Internal port";
}; };
@ -30,7 +30,7 @@ in
settings = { settings = {
dns.base_domain = "buehler.internal"; dns.base_domain = "buehler.internal";
server_url = "https://vpn.${domain}"; server_url = "https://vpn.${domain}";
metrics_listen_addr = "127.0.0.1:8095"; metrics_listen_addr = "127.0.0.1:8091";
log.level = "warn"; log.level = "warn";
}; };
}; };
@ -41,7 +41,7 @@ in
job_name = "headscale"; job_name = "headscale";
static_configs = [ static_configs = [
{ {
targets = [ "localhost:8095" ]; targets = [ "localhost:8091" ];
labels = { labels = {
instance = config.networking.hostName; instance = config.networking.hostName;
}; };