diff --git a/hosts/tram-borzoi/borzoi.nix b/hosts/tram-borzoi/borzoi.nix index 37254c6..695a3f8 100644 --- a/hosts/tram-borzoi/borzoi.nix +++ b/hosts/tram-borzoi/borzoi.nix @@ -1,23 +1,11 @@ -{ config, ... }: -let - borzoi-port = 8080; -in +{ config, registry, ... }: { - networking.firewall.allowedTCPPorts = [ borzoi-port ]; + networking.firewall.allowedTCPPorts = [ registry.port-borzoi.port ]; TLMS.borzoi = { enable = true; - http = { - host = "0.0.0.0"; - port = borzoi-port; - }; - database = { - host = "127.0.0.1"; - port = config.services.postgresql.port; - passwordFile = config.sops.secrets.postgres-borzoi-pw.path; - user = "borzoi"; - database = "borzoi"; - }; + http = registry.port-borzoi; + database = registry.postgres; }; users.users.borzoi = { diff --git a/hosts/tram-borzoi/postgres.nix b/hosts/tram-borzoi/postgres.nix index 08e82bd..a584455 100644 --- a/hosts/tram-borzoi/postgres.nix +++ b/hosts/tram-borzoi/postgres.nix @@ -1,4 +1,4 @@ -{ lib, pkgs, config, inputs, self, ... }: { +{ lib, pkgs, config, inputs, self, registry, ... }: { sops.secrets.postgres-borzoi-pw = { owner = config.users.users.postgres.name; @@ -9,14 +9,13 @@ owner = config.users.users.postgres.name; }; services.postgresql = { + inherit (registry.postgres) port; enable = true; enableTCPIP = true; - port = 5432; authentication = let senpai-ip = self.unevaluatedNixosConfigurations.notice-me-senpai.specialArgs.registry.wgAddr4; - # TODO: fixme - uranus-ip = "10.13.37.9"; + uranus-ip = self.unevaluatedNixosConfigurations.uranus.specialArgs.registry.wgAddr4; in pkgs.lib.mkOverride 10 '' local all all trust diff --git a/modules/traffic-stop-box/radio-config.nix b/modules/traffic-stop-box/radio-config.nix index a993e91..1176bcc 100644 --- a/modules/traffic-stop-box/radio-config.nix +++ b/modules/traffic-stop-box/radio-config.nix @@ -1,12 +1,17 @@ -{ config, lib, registry, ... }: +{ self, config, lib, registry, ... }: { TLMS.gnuradio = { enable = true; } // registry.gnuradio; - TLMS.telegramDecoder = { + # find all the servers with data-accumulator configured + TLMS.telegramDecoder = let + registries = builtins.attrValues (builtins.mapAttrs (name: value: value.specialArgs.registry) self.unevaluatedNixosConfigurations); + filteredDataHoarders = builtins.filter (other: other ? port-data_accumulator) registries; + urlFromRegistry = other: "http://${other.wgAddr4}:${toString other.port-data_accumulator.port}"; + in { enable = true; - server = [ "http://10.13.37.1:8080" "http://10.13.37.5:8080" "http://10.13.37.7:8080" ]; + server = builtins.map urlFromRegistry filteredDataHoarders; configFile = registry.telegramDecoderConfig; authTokenFile = config.sops.secrets.telegram-decoder-token.path; }; diff --git a/registry/default.nix b/registry/default.nix index 1fddcfc..e460383 100644 --- a/registry/default.nix +++ b/registry/default.nix @@ -33,5 +33,16 @@ wgAddr4 = "10.13.37.8"; wireguardPublicKey = "wCW+r5kAaIarvZUWf4KsJNetyHobP0nNy5QOhqmsCCs="; publicWireguardEndpoint = null; + postgres = { + host = "127.0.0.1"; + port = 5432; + passwordFile = "/run/secrets/postgres-borzoi-pw"; + user = "borzoi"; + database = "borzoi"; + }; + port-borzoi = { + host = "0.0.0.0"; + port = 8080; + }; }; }