From 6f8f7239dc276479d691dcd0ffb5124bd62032ad Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Thu, 18 Sep 2025 08:52:11 +0200 Subject: feat(ev): add miniflux I already had a miniflux instance a couple years ago but accidentally dropped the database. --- nixos/hosts/ev/default.nix | 5 +++++ nixos/hosts/ev/exporters.nix | 42 ++++++++++++++++++++++++++++++++++++++++++ nixos/hosts/ev/miniflux.nix | 27 +++++++++++++++++++++++++++ nixos/hosts/ev/ports.nix | 3 +++ 4 files changed, 77 insertions(+) create mode 100644 nixos/hosts/ev/exporters.nix create mode 100644 nixos/hosts/ev/miniflux.nix (limited to 'nixos/hosts') diff --git a/nixos/hosts/ev/default.nix b/nixos/hosts/ev/default.nix index 74518f0..fbda40f 100644 --- a/nixos/hosts/ev/default.nix +++ b/nixos/hosts/ev/default.nix @@ -13,11 +13,14 @@ in ./hardware-configuration.nix + + ./exporters.nix ./home-automation.nix ./kodi.nix + ./miniflux.nix ./torrent.nix ./hosehawk.nix ]; @@ -49,7 +52,9 @@ in monitoring.lokiPort = ports.grafanaLoki; monitoring.prometheusPort = ports.prometheus; monitoring.prometheusNodeExporterPort = ports.prometheusNodeExporter; + exporters.sqlExporterPort = ports.prometheusSqlExporter; hosehawk.port = ports.hosehawk; + miniflux.port = ports.miniflux; home-automation.zigbeeSerialPort = "/dev/serial/by-id/usb-ITead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_e2fed465c59ded11962fd7a5a7669f5d-if00-port0"; diff --git a/nixos/hosts/ev/exporters.nix b/nixos/hosts/ev/exporters.nix new file mode 100644 index 0000000..1c03c35 --- /dev/null +++ b/nixos/hosts/ev/exporters.nix @@ -0,0 +1,42 @@ +{ config, lib, pkgs, ... }: + +let + helpers = import { inherit config lib pkgs; }; + cfg = config.exporters; +in +{ + options.exporters = { + sqlExporterPort = lib.mkOption { + type = lib.types.int; + }; + }; + + imports = [ + + ]; + + config = { + services.prometheus-sql-exporter = { + enable = true; + port = cfg.sqlExporterPort; + config = { + target = { + # This URL should be postgresql:///postgres?host=/run/postgresql + # but sql_exporter uses xo/dburl which isn't spec-compliant: https://github.com/xo/dburl/issues/46 + data_source_name = "postgresql:/run/postgresql:/postgres"; + collectors = helpers.collectorNames; + }; + collectors = helpers.collectors; + }; + }; + + monitoring.prometheusScrapeConfigs = [ + { + job_name = "sql"; + static_configs = [{ + targets = [ "localhost:${toString cfg.sqlExporterPort}" ]; + }]; + } + ]; + }; +} diff --git a/nixos/hosts/ev/miniflux.nix b/nixos/hosts/ev/miniflux.nix new file mode 100644 index 0000000..5bf1ccd --- /dev/null +++ b/nixos/hosts/ev/miniflux.nix @@ -0,0 +1,27 @@ +{ config, lib, pkgs, ... }: + +let + cfg = config.miniflux; +in +{ + options.miniflux = { + port = lib.mkOption { + type = lib.types.int; + }; + }; + + config = { + age.secrets.miniflux-admin.file = ; + + services.miniflux = { + enable = true; + config = { + LISTEN_ADDR = "0.0.0.0:${toString cfg.port}"; + DATABASE_URL = "user=miniflux host=/run/postgresql dbname=miniflux"; + }; + # miniflux does not support disabling its authentication. https://github.com/miniflux/v2/issues/408 + adminCredentialsFile = config.age.secrets.miniflux-admin.path; + createDatabaseLocally = false; + }; + }; +} diff --git a/nixos/hosts/ev/ports.nix b/nixos/hosts/ev/ports.nix index cd41d1b..502e190 100644 --- a/nixos/hosts/ev/ports.nix +++ b/nixos/hosts/ev/ports.nix @@ -2,8 +2,10 @@ rec { grafanaAlloy = 3001; grafanaLoki = 3030; hosehawk = 4000; + miniflux = 4001; prometheus = 9090; prometheusNodeExporter = 9002; + prometheusSqlExporter = 9003; qbittorrent = 7777; zigbee2mqtt = 8080; @@ -11,6 +13,7 @@ rec { inherit grafanaAlloy hosehawk + miniflux prometheus qbittorrent zigbee2mqtt -- cgit v1.2.3