From e7d81af57fe372e08b7d0193d31a9ff614d7a737 Mon Sep 17 00:00:00 2001 From: Max Audron Date: Fri, 1 Aug 2025 15:45:28 +0200 Subject: add homepage dashboard --- flake.nix | 1 + modules/default.nix | 1 + modules/homepage/default.nix | 242 +++++++++++++++++++++++++++++++++++++++++ modules/monitoring/default.nix | 19 +++- modules/tlmp/default.nix | 24 +++- secrets | 2 +- 6 files changed, 285 insertions(+), 4 deletions(-) create mode 100644 modules/homepage/default.nix diff --git a/flake.nix b/flake.nix index 5ec3a68..8fd66ae 100644 --- a/flake.nix +++ b/flake.nix @@ -105,6 +105,7 @@ # litellm monitoring monitoring-node + homepage ]; phaenn = mkSystem [ (import ./machines/phaenn) diff --git a/modules/default.nix b/modules/default.nix index 59faed7..934aa4e 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -34,4 +34,5 @@ monitoring = import ./monitoring; monitoring-node = import ./monitoring/node-exporter.nix; + homepage = import ./homepage; } diff --git a/modules/homepage/default.nix b/modules/homepage/default.nix new file mode 100644 index 0000000..3dafa47 --- /dev/null +++ b/modules/homepage/default.nix @@ -0,0 +1,242 @@ +{ self, config, lib, pkgs, ... }: + +with self.lib.nginx; +{ + services.homepage-dashboard = { + enable = true; + allowedHosts = "vapor.systems"; + + environmentFile = config.secrets.homepage.dest; + + settings = { + hideVersion = true; + + headerStyle = "clean"; + statusStyle = "dot"; + + theme = "dark"; + background = "/images/backgrounds/wallhaven-39gogv.jpg"; + cardBlur = "xl"; + + useEqualHeights = true; + layout = [ + { + "Media" = { + style = "row"; + columns = 5; + }; + } + { + "Games" = { + style = "row"; + columns = 4; + }; + } + { + "Hosting" = { + style = "row"; + columns = 2; + header = false; + "Monitoring" = { + style = "row"; + columns = 1; + }; + "Development" = { + style = "row"; + columns = 2; + }; + }; + } + ]; + }; + + services = [ + { + "Media" = [ + { + "Jellyfin" = { + icon = "sh-jellyfin"; + description = "Media Server"; + href = "https://media.cocaine.farm"; + siteMonitor = "https://media.cocaine.farm"; + + widget = { + type = "jellyfin"; + url = "https://media.cocaine.farm"; + key = "{{HOMEPAGE_VAR_JELLYFIN_KEY}}"; + enableBlocks = true; + enableNowPlaying = true; + enableUser = true; + enableMediaControl = false; + showEpisodeNumber = false; + expandOneStreamToTwoRows = false; + }; + }; + } + { + "Radarr" = { + icon = "sh-radarr"; + description = "Movie Management"; + href = "https://radarr.media.cocaine.farm"; + siteMonitor = "https://radarr.media.cocaine.farm"; + widget = { + type = "radarr"; + url = "http://phaenn:7878"; + key = "{{HOMEPAGE_VAR_RADARR_KEY}}"; + enableQueue = true; + }; + }; + } + { + "Sonarr" = { + icon = "sh-sonarr"; + description = "Series Management"; + href = "https://sonarr.media.cocaine.farm"; + siteMonitor = "https://sonarr.media.cocaine.farm"; + widget = { + type = "sonarr"; + url = "http://phaenn:8989"; + key = "{{HOMEPAGE_VAR_SONARR_KEY}}"; + enableQueue = true; + }; + }; + } + { + "Prowlarr" = { + icon = "sh-prowlarr"; + description = "Tracker Management"; + href = "https://prowlarr.media.cocaine.farm"; + siteMonitor = "https://prowlarr.media.cocaine.farm"; + widget = { + type = "prowlarr"; + url = "http://phaenn:9696"; + key = "{{HOMEPAGE_VAR_PROWLARR_KEY}}"; + }; + }; + } + { + "ruTorrent" = { + icon = "/images/icons/rutorrent.png"; + description = "Torrent Client"; + href = "https://torrent.media.cocaine.farm"; + siteMonitor = "https://torrent.media.cocaine.farm"; + widget = { + type = "rutorrent"; + url = "http://10.10.0.2"; + }; + }; + } + ]; + } + { + "Games" = [ + { "Minecraft - Dungeons & Taverns" = { + icon = "sh-minecraft"; + description = "c0re.space:25566"; + widgets = [ + { type = "prometheusmetric"; + url = "http://ettves:9090"; + refreshInterval = 10000; + metrics = [ + { label = "Players"; + query = ''sum(minecraft_players_online)''; + } + { label = "TPS"; + query = ''round(minecraft_tps)''; + } + ]; + } + ]; + }; + } + { "Minecraft - Vanilla" = { + icon = "sh-minecraft"; + description = "c0re.space:25565"; + widgets = [ + { type = "prometheusmetric"; + url = "http://ettves:9090"; + refreshInterval = 10000; + metrics = [ + { label = "Players"; + query = ''sum(mc_players_online_total)''; + } + { label = "TPS"; + query = ''round(mc_tps)''; + } + ]; + } + ]; + }; + } + { "Factorio - Space Age" = { + icon = "/images/icons/factorio.png"; + description = "cocaine.farm"; + }; + } + { "Assetto Corsa Competizione" = { + icon = "/images/icons/ac-logo-white.svg"; + description = "cocaine.farm:9231"; + }; + } + ]; + } + { + "Hosting" = [ + { + "Monitoring" = [ + { + "Prometheus" = { + icon = "sh-prometheus"; + description = "Monitoring & Metrics Database"; + href = "https://prometheus.vapor.systems"; + siteMonitor = "https://prometheus.vapor.systems"; + }; + } + ]; + } + { + "Development" = [ + { + "Gitea" = { + icon = "sh-gitea"; + description = "Git Repository Host"; + href = "https://git.vapor.systems"; + siteMonitor = "https://git.vapor.systems"; + }; + } + { + "Hydra" = { + icon = "sh-nixos"; + description = "Nix Build System"; + href = "https://hydra.vapor.systems"; + siteMonitor = "https://hydra.vapor.systems"; + }; + } + ]; + } + ]; + } + ]; + }; + + secrets = { + homepage = { + source = ../../secrets/homepage.env; + dest = "/etc/secrets/homepage.env"; + }; + }; + + services.nginx = { + enable = true; + virtualHosts = { + "vapor.systems" = lib.mkMerge [ + (proxyDomain "vapor.systems" "http://localhost:8082/") + { + locations."/images" = { + root = "/var/www/vapor.systems"; + }; + } + ]; + }; + }; +} diff --git a/modules/monitoring/default.nix b/modules/monitoring/default.nix index fe49c00..d2e4bc3 100644 --- a/modules/monitoring/default.nix +++ b/modules/monitoring/default.nix @@ -9,7 +9,7 @@ in { enableReload = true; retentionTime = "14d"; - listenAddress = "10.10.0.1"; + listenAddress = "0.0.0.0"; webExternalUrl = "https://prometheus.vapor.systems"; globalConfig = { @@ -36,7 +36,22 @@ in { (mkScrapeConfig "garage" [ "fra01" "nyc01" "sin01" ] 3903) (mkScrapeConfig "pdns" [ "ettves" "fra01" "nyc01" "sin01" ] 8081) - (mkScrape "minecraft" [ "ettves:25585" "ettves:9150" ]) + ((mkScrape "minecraft" [ "ettves:25585" "ettves:9150" "ettves:9225" ]) // { + relabel_configs = [ + { + source_labels = ["__address__"]; + target_label = "server"; + regex = "(ettves:25585)|(ettves:9150)"; + replacement = "dungeons"; + } + { + source_labels = ["__address__"]; + target_label = "server"; + regex = "(ettves:9225)"; + replacement = "vanilla"; + } + ]; + }) ]; }; diff --git a/modules/tlmp/default.nix b/modules/tlmp/default.nix index ddb9ff3..8019ccd 100644 --- a/modules/tlmp/default.nix +++ b/modules/tlmp/default.nix @@ -44,7 +44,7 @@ with self.lib.nginx; services.rutorrent = { enable = true; hostName = "torrent.media.cocaine.farm"; - plugins = lib.mkForce [ "data" "diskspace" "edit" "erasedata" "theme" "trafic" ]; + plugins = lib.mkForce [ "httprpc" "data" "diskspace" "edit" "erasedata" "theme" "trafic" ]; nginx.enable = true; }; @@ -73,12 +73,34 @@ with self.lib.nginx; port = 80; }]; + serverAliases = [ "phaenn.wg.vapor.systems" ]; + locations."/RPC2" = { extraConfig = '' include ${pkgs.nginx}/conf/scgi_params; scgi_pass unix:/run/rtorrent/rpc.sock; ''; }; + + root = config.services.rutorrent.dataDir; + locations = { + "~ [^/]\\.php(/|$)" = { + extraConfig = '' + fastcgi_split_path_info ^(.+?\.php)(/.*)$; + if (!-f $document_root$fastcgi_script_name) { + return 404; + } + + # Mitigate https://httpoxy.org/ vulnerabilities + fastcgi_param HTTP_PROXY ""; + + fastcgi_pass unix:${config.services.phpfpm.pools.rutorrent.socket}; + fastcgi_index index.php; + + include ${pkgs.nginx}/conf/fastcgi.conf; + ''; + }; + }; }; }; }; diff --git a/secrets b/secrets index 10079a5..d5924d5 160000 --- a/secrets +++ b/secrets @@ -1 +1 @@ -Subproject commit 10079a53596523af7c8294e73e688b87ba1513e5 +Subproject commit d5924d53340d1a26c02e67fbff0b2220bdc39aba -- cgit v1.2.3