Skip to content

Commit

Permalink
Merge pull request #22 from hauskens/main
Browse files Browse the repository at this point in the history
feat(extractors/services): Add support for Static Web Server and Traefik
  • Loading branch information
oddlama authored May 1, 2024
2 parents ac69cc7 + 9cf6f6f commit f944867
Show file tree
Hide file tree
Showing 2 changed files with 40 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.
39 changes: 39 additions & 0 deletions nixos/extractors/services.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
genAttrs
concatLines
concatStringsSep
elemAt
filterAttrs
flatten
flip
imap0
length
listToAttrs
mapAttrs
mapAttrsToList
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit f944867

Please sign in to comment.