From e721a2088b8f6b821e7ab8f6120cf85913d7f4ed Mon Sep 17 00:00:00 2001 From: cnst Date: Fri, 26 Sep 2025 17:41:19 +0200 Subject: [PATCH] feat(homepage-dashboard): adding some disk info --- modules/server/homepage-dashboard/default.nix | 216 ++++++++++-------- 1 file changed, 115 insertions(+), 101 deletions(-) diff --git a/modules/server/homepage-dashboard/default.nix b/modules/server/homepage-dashboard/default.nix index feb0b561..b0a49877 100644 --- a/modules/server/homepage-dashboard/default.nix +++ b/modules/server/homepage-dashboard/default.nix @@ -2,17 +2,19 @@ config, lib, ... -}: let +}: +let unit = "homepage-dashboard"; cfg = config.server.homepage-dashboard; srv = config.server; -in { +in +{ options.server.homepage-dashboard = { enable = lib.mkEnableOption { description = "Enable ${unit}"; }; misc = lib.mkOption { - default = []; + default = [ ]; type = lib.types.listOf ( lib.types.attrsOf ( lib.types.submodule { @@ -103,118 +105,128 @@ in { } { resources = { - label = ""; + label = "root"; memory = true; - disk = ["/"]; + disk = [ "/dev/dm-1" ]; + }; + } + { + resources = { + label = "zfs"; + memory = true; + disk = [ "/mnt/data" ]; }; } ]; - - services = let - homepageCategories = [ - "Arr" - "Media" - "Downloads" - "Services" - "Smart Home" - ]; - hl = config.server; - mergedServices = hl // hl.podman; - homepageServices = x: (lib.attrsets.filterAttrs ( - name: value: value ? homepage && value.homepage.category == x - ) - mergedServices); - in + services = + let + homepageCategories = [ + "Arr" + "Media" + "Downloads" + "Services" + "Smart Home" + ]; + hl = config.server; + mergedServices = hl // hl.podman; + homepageServices = + x: + (lib.attrsets.filterAttrs ( + name: value: value ? homepage && value.homepage.category == x + ) mergedServices); + in lib.lists.forEach homepageCategories (cat: { "${cat}" = lib.lists.forEach - (lib.attrsets.mapAttrsToList (name: value: { - inherit name; - url = value.url; - homepage = value.homepage; - }) (homepageServices "${cat}")) - (x: { - "${x.homepage.name}" = { - icon = x.homepage.icon; - description = x.homepage.description; - href = "https://${x.url}${x.homepage.path or ""}"; - siteMonitor = "https://${x.url}${x.homepage.path or ""}"; - }; - }); + (lib.attrsets.mapAttrsToList (name: value: { + inherit name; + url = value.url; + homepage = value.homepage; + }) (homepageServices "${cat}")) + (x: { + "${x.homepage.name}" = { + icon = x.homepage.icon; + description = x.homepage.description; + href = "https://${x.url}${x.homepage.path or ""}"; + siteMonitor = "https://${x.url}${x.homepage.path or ""}"; + }; + }); }) - ++ [{Misc = cfg.misc;}] + ++ [ { Misc = cfg.misc; } ] ++ [ { - Glances = let - port = toString config.services.glances.port; - in [ - { - Info = { - widget = { - type = "glances"; - url = "http://localhost:${port}"; - metric = "info"; - chart = false; - version = 4; + Glances = + let + port = toString config.services.glances.port; + in + [ + { + Info = { + widget = { + type = "glances"; + url = "http://localhost:${port}"; + metric = "info"; + chart = false; + version = 4; + }; }; - }; - } - { - "CPU Temp" = { - widget = { - type = "glances"; - url = "http://localhost:${port}"; - metric = "sensor:Tctl"; - chart = false; - version = 4; + } + { + "CPU Temp" = { + widget = { + type = "glances"; + url = "http://localhost:${port}"; + metric = "sensor:Tctl"; + chart = false; + version = 4; + }; }; - }; - } - { - "GPU Radeon" = { - widget = { - type = "glances"; - url = "http://localhost:${port}"; - metric = "sensor:junction"; - chart = false; - version = 4; + } + { + "GPU Radeon" = { + widget = { + type = "glances"; + url = "http://localhost:${port}"; + metric = "sensor:junction"; + chart = false; + version = 4; + }; }; - }; - } - { - "GPU Intel" = { - widget = { - type = "glances"; - url = "http://localhost:${port}"; - metric = "sensor:pkg"; - chart = false; - version = 4; + } + { + "GPU Intel" = { + widget = { + type = "glances"; + url = "http://localhost:${port}"; + metric = "sensor:pkg"; + chart = false; + version = 4; + }; }; - }; - } - { - Processes = { - widget = { - type = "glances"; - url = "http://localhost:${port}"; - metric = "process"; - chart = false; - version = 4; + } + { + Processes = { + widget = { + type = "glances"; + url = "http://localhost:${port}"; + metric = "process"; + chart = false; + version = 4; + }; }; - }; - } - { - Network = { - widget = { - type = "glances"; - url = "http://localhost:${port}"; - metric = "network:enp6s0"; - chart = false; - version = 4; + } + { + Network = { + widget = { + type = "glances"; + url = "http://localhost:${port}"; + metric = "network:enp6s0"; + chart = false; + version = 4; + }; }; - }; - } - ]; + } + ]; } ]; }; @@ -222,10 +234,12 @@ in { traefik = { dynamicConfigOptions = { http = { - services.homepage.loadBalancer.servers = [{url = "http://127.0.0.1:${toString config.services.${unit}.listenPort}";}]; + services.homepage.loadBalancer.servers = [ + { url = "http://127.0.0.1:${toString config.services.${unit}.listenPort}"; } + ]; routers = { homepage = { - entryPoints = ["websecure"]; + entryPoints = [ "websecure" ]; rule = "Host(`cnix.dev`)"; service = "homepage"; tls.certResolver = "letsencrypt";