Skip to content

Commit

Permalink
feat(extractors/services): Add support for traefik
Browse files Browse the repository at this point in the history
  • Loading branch information
hauskens authored and IogaMaster committed May 1, 2024
1 parent 9715dfa commit 1528de0
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions icons/services/traefik.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions nixos/extractors/services.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
genAttrs
concatLines
concatStringsSep
elemAt
filterAttrs
flatten
flip
forEach
head
imap0
length
listToAttrs
mapAttrs
mapAttrsToList
Expand Down Expand Up @@ -350,6 +352,34 @@ in {
};
};

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;
Expand Down

0 comments on commit 1528de0

Please sign in to comment.