From e48cd0581b768f578d3f2a7f60b306fb0bf8d227 Mon Sep 17 00:00:00 2001 From: oddlama Date: Mon, 1 Apr 2024 16:18:45 +0200 Subject: [PATCH] feat(topology): improve details readability --- topology/README.md | 1 + topology/nixos/extractors/services.nix | 11 +++++++---- topology/nixos/extractors/systemd-network.nix | 4 ++-- topology/topology/renderers/svg/default.nix | 7 ++++--- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/topology/README.md b/topology/README.md index a5fb0c4..8b5b9a1 100644 --- a/topology/README.md +++ b/topology/README.md @@ -14,6 +14,7 @@ - impermanence render? - nixos nftables firewall render? +- make colors configurable - search todo and do - the network propagator based on options.nodes cannot deal with mkMerge and mkIf stuff currently diff --git a/topology/nixos/extractors/services.nix b/topology/nixos/extractors/services.nix index fcf0a87..2ceb3ac 100644 --- a/topology/nixos/extractors/services.nix +++ b/topology/nixos/extractors/services.nix @@ -14,6 +14,7 @@ mkDefault mkEnableOption mkIf + mkMerge optional replaceStrings ; @@ -76,8 +77,8 @@ in { nginx = mkIf config.services.nginx.enable { name = "NGINX"; icon = "services.nginx"; - details.reverse = let - lines = flatten (flip mapAttrsToList config.services.nginx.virtualHosts ( + details = let + reverseProxies = flatten (flip mapAttrsToList config.services.nginx.virtualHosts ( server: vh: flip mapAttrsToList vh.locations ( path: location: let @@ -87,11 +88,13 @@ in { then toString (attrNames config.services.nginx.upstreams.${upstreamName}.servers) else location.proxyPass; in - optional (path == "/" && location.proxyPass != null) "${server} -> ${passTo}" + optional (path == "/" && location.proxyPass != null) { + ${server} = {text = passTo;}; + } ) )); in - mkIf (lines != []) {text = concatLines lines;}; + mkMerge reverseProxies; }; radicale = mkIf config.services.radicale.enable { diff --git a/topology/nixos/extractors/systemd-network.nix b/topology/nixos/extractors/systemd-network.nix index 97e7e2c..4b1cc6a 100644 --- a/topology/nixos/extractors/systemd-network.nix +++ b/topology/nixos/extractors/systemd-network.nix @@ -50,8 +50,8 @@ in { ++ concatLists ( flip mapAttrsToList config.systemd.network.networks ( _unit: network: let - # FIXME: TODO renameInterfacesByMac is not a standard option! - macToName = listToAttrs (mapAttrsToList (k: v: nameValuePair v k) config.networking.renameInterfacesByMac); + # FIXME: TODO renameInterfacesByMac is not a standard option! It's not an issue here but should proabaly not be used anyway. + macToName = listToAttrs (mapAttrsToList (k: v: nameValuePair v k) (config.networking.renameInterfacesByMac or {})); nameFromMac = optional (network ? matchConfig.MACAddress && macToName ? ${network.matchConfig.MACAddress}) diff --git a/topology/topology/renderers/svg/default.nix b/topology/topology/renderers/svg/default.nix index f4195cf..ed4ac68 100644 --- a/topology/topology/renderers/svg/default.nix +++ b/topology/topology/renderers/svg/default.nix @@ -179,9 +179,10 @@ html */ '' -
- ${detail.name} - ${detail.text} +
+ ${detail.name} + + ${detail.text}
'';