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; {
enable = mkEnableOption "Prometheus alertmanager for monitoring";
port = mkOption {
type = types.port;
default = 9093;
example = 3002;
description = "Internal alertmanager port";
};
};
config = lib.mkIf cfg.enable {
@ -34,20 +28,27 @@ in
prometheus = {
alertmanager = {
enable = true;
inherit (cfg) port;
configuration = import ./config.nix;
webExternalUrl = "https://alerts.${domain}";
# 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 = [
{
job_name = "alertmanager";
static_configs = [
{
targets = [ "localhost:${toString cfg.port}" ];
targets = [ "localhost:${toString config.services.prometheus.alertmanager.port}" ];
labels = {
instance = config.networking.hostName;
};
@ -62,7 +63,7 @@ in
{
name = "Alertmanager";
type = "alertmanager";
url = "http://localhost:${toString cfg.port}";
url = "http://localhost:${toString config.services.prometheus.alertmanager.port}";
jsonData = {
implementation = "prometheus";
handleGrafanaManagedAlerts = config.services.prometheus.enable;
@ -135,7 +136,7 @@ in
my.services.webserver.virtualHosts = [
{
subdomain = "alerts";
inherit (cfg) port;
inherit (config.services.prometheus.alertmanager) port;
}
];

View file

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

View file

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

View file

@ -12,12 +12,6 @@ in
{
options.my.services.gitea = with lib; {
enable = mkEnableOption "Gitea";
port = mkOption {
type = types.port;
default = 3042;
example = 8080;
description = "Internal port";
};
};
config = lib.mkIf cfg.enable {
@ -26,7 +20,7 @@ in
enable = true;
settings = {
server = {
HTTP_PORT = cfg.port;
HTTP_PORT = 3042;
ROOT_URL = "https://code.${domain}";
};
session.COOKIE_SECURE = true;
@ -44,7 +38,7 @@ in
job_name = "gitea";
static_configs = [
{
targets = [ "localhost:${toString cfg.port}" ];
targets = [ "localhost:${toString config.services.gitea.settings.server.HTTP_PORT}" ];
labels = {
instance = config.networking.hostName;
};
@ -69,7 +63,7 @@ in
webserver.virtualHosts = [
{
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; {
enable = mkEnableOption "Grafana for visualizing";
port = mkOption {
type = types.port;
default = 9500;
example = 3001;
description = "Internal port";
};
username = mkOption {
type = types.str;
default = "felix";
@ -42,7 +35,6 @@ in
server = {
domain = "visualization.${domain}";
root_url = "https://visualization.${domain}/";
http_port = cfg.port;
};
security = {
@ -69,7 +61,7 @@ in
job_name = "grafana";
static_configs = [
{
targets = [ "localhost:${toString cfg.port}" ];
targets = [ "localhost:${toString config.services.grafana.settings.server.http_port}" ];
labels = {
instance = config.networking.hostName;
};
@ -82,7 +74,7 @@ in
my.services.webserver.virtualHosts = [
{
subdomain = "visualization";
inherit (cfg) port;
port = config.services.grafana.settings.server.http_port;
}
];

View file

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

View file

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

View file

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

View file

@ -7,18 +7,13 @@
}:
let
cfg = config.my.services.loki;
# no default port defined in nixpkgs
port = 3101;
in
{
options.my.services.loki = with lib; {
enable = mkEnableOption "loki log monitoring";
port = mkOption {
type = types.port;
default = 3100;
example = 3002;
description = "Internal port";
};
rules = mkOption {
type = types.attrsOf (
types.submodule {
@ -91,7 +86,7 @@ in
configuration = {
server = {
http_listen_address = "localhost";
http_listen_port = cfg.port;
http_listen_port = port;
};
auth_enabled = false;
@ -113,7 +108,7 @@ in
local.directory = "${config.services.loki.dataDir}/ruler";
};
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;
};
@ -151,7 +146,7 @@ in
name = "Loki";
type = "loki";
access = "proxy";
url = "http://localhost:${toString cfg.port}";
url = "http://localhost:${toString port}";
}
];
dashboards.settings.providers = [
@ -169,7 +164,7 @@ in
job_name = "loki";
static_configs = [
{
targets = [ "localhost:${toString cfg.port}" ];
targets = [ "localhost:${toString port}" ];
labels = {
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 {
type = types.str;
example = "/mnt/music/";
@ -49,7 +42,6 @@ in
enable = true;
settings = cfg.settings // {
Port = cfg.port;
MusicFolder = cfg.musicFolder;
LogLevel = "info";
Prometheus.Enabled = config.services.prometheus.enable;
@ -62,7 +54,7 @@ in
job_name = "navidrome";
static_configs = [
{
targets = [ "localhost:${toString cfg.port}" ];
targets = [ "localhost:${toString config.services.navidrome.settings.Port}" ];
labels = {
instance = config.networking.hostName;
};
@ -92,7 +84,7 @@ in
my.services.webserver.virtualHosts = [
{
subdomain = "music";
inherit (cfg) port;
port = config.services.navidrome.settings.Port;
}
];

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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