diff --git a/icons/services/traefik.svg b/icons/services/traefik.svg new file mode 100644 index 0000000..7a707dd --- /dev/null +++ b/icons/services/traefik.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/nixos/extractors/services.nix b/nixos/extractors/services.nix index 025b2f3..a952e8f 100644 --- a/nixos/extractors/services.nix +++ b/nixos/extractors/services.nix @@ -9,10 +9,12 @@ genAttrs concatLines concatStringsSep + elemAt filterAttrs flatten flip imap0 + length listToAttrs mapAttrs mapAttrsToList @@ -339,6 +341,43 @@ in { details.listen = mkIf config.services.sonarr.openFirewall {text = "0.0.0.0:8989";}; }; + static-web-server = mkIf config.services.static-web-server.enable { + name = "Static Web Server"; + icon = "devices.nixos"; + details = { + listen.text = toString config.services.static-web-server.listen; + root.text = toString config.services.static-web-server.root; + }; + }; + + traefik = let + dynCfg = config.services.traefik.dynamicConfigOptions; + in + mkIf config.services.traefik.enable { + name = "Traefik"; + icon = "services.traefik"; + details = mkIf (length (attrNames dynCfg) > 0) (let + formatOutput = + mapAttrsToList ( + routerName: routerAttrs: let + getServiceUrl = serviceName: let + service = dynCfg.http.services.${toString serviceName}.loadBalancer.servers or []; + in + if length service > 0 + then (elemAt service 0).url + else "invalid service"; + passText = toString (getServiceUrl routerAttrs.service); + in { + ${toString routerName} = { + text = passText; + }; + } + ) + dynCfg.http.routers; + in + mkMerge formatOutput); + }; + transmission = let address = config.services.transmission.settings.rpc-bind-address or null; port = config.services.transmission.settings.rpc-port or null;