diff --git a/nixos/doc/manual/release-notes/rl-2511.section.md b/nixos/doc/manual/release-notes/rl-2511.section.md index 8dc6829d7182..7056f7fd144f 100644 --- a/nixos/doc/manual/release-notes/rl-2511.section.md +++ b/nixos/doc/manual/release-notes/rl-2511.section.md @@ -146,6 +146,8 @@ - [KMinion](https://github.com/redpanda-data/kminion), feature-rich Prometheus exporter for Apache Kafka. Available as [services.prometheus.exporters.kafka](options.html#opt-services.prometheus.exporters.kafka). +- [Beszel](https://beszel.dev), a lightweight server monitoring hub with historical data, docker stats, and alerts. Available as `services.beszel.hub`. + - [Spoolman](https://github.com/Donkie/Spoolman), a inventory management system for Filament spools. Available as [services.spoolman](#opt-services.spoolman.enable). - [Temporal](https://temporal.io/), a durable execution platform that enables diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 457d7923fd63..27ce3ddc3b86 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -973,6 +973,7 @@ ./services/monitoring/apcupsd.nix ./services/monitoring/arbtt.nix ./services/monitoring/below.nix + ./services/monitoring/beszel-hub.nix ./services/monitoring/bosun.nix ./services/monitoring/cadvisor.nix ./services/monitoring/certspotter.nix diff --git a/nixos/modules/services/monitoring/beszel-hub.nix b/nixos/modules/services/monitoring/beszel-hub.nix new file mode 100644 index 000000000000..8028d13c39d3 --- /dev/null +++ b/nixos/modules/services/monitoring/beszel-hub.nix @@ -0,0 +1,114 @@ +{ + lib, + config, + pkgs, + ... +}: +let + cfg = config.services.beszel.hub; +in +{ + meta.maintainers = with lib.maintainers; [ + BonusPlay + arunoruto + ]; + + options.services.beszel.hub = { + enable = lib.mkEnableOption "beszel hub"; + + package = lib.mkPackageOption pkgs "beszel" { }; + + host = lib.mkOption { + default = "127.0.0.1"; + type = lib.types.str; + example = "0.0.0.0"; + description = "Host or address this beszel hub listens on."; + }; + port = lib.mkOption { + default = 8090; + type = lib.types.port; + example = 3002; + description = "Port for this beszel hub to listen on."; + }; + + dataDir = lib.mkOption { + type = lib.types.path; + default = "/var/lib/beszel-hub"; + description = "Data directory of beszel-hub."; + }; + + environment = lib.mkOption { + type = with lib.types; attrsOf str; + default = { }; + example = { + DISABLE_PASSWORD_AUTH = "true"; + }; + description = '' + Environment variables passed to the systemd service. + See for available options. + ''; + }; + environmentFile = lib.mkOption { + type = lib.types.nullOr lib.types.path; + default = null; + description = '' + Environment file to be passed to the systemd service. + Useful for passing secrets to the service to prevent them from being + world-readable in the Nix store. See {manpage}`systemd.exec(5)`. + ''; + }; + }; + + config = lib.mkIf cfg.enable { + systemd.services.beszel-hub = { + description = "Beszel Server Monitoring Web App"; + + wantedBy = [ "multi-user.target" ]; + wants = [ "network-online.target" ]; + after = [ "network-online.target" ]; + environment = cfg.environment; + + serviceConfig = { + ExecStartPre = [ + "${cfg.package}/bin/beszel-hub migrate up" + "${cfg.package}/bin/beszel-hub history-sync" + ]; + ExecStart = '' + ${cfg.package}/bin/beszel-hub serve --http='${cfg.host}:${toString cfg.port}' + ''; + + EnvironmentFile = lib.mkIf (cfg.environmentFile != null) cfg.environmentFile; + WorkingDirectory = cfg.dataDir; + StateDirectory = baseNameOf cfg.dataDir; + RuntimeDirectory = baseNameOf cfg.dataDir; + ReadWritePaths = cfg.dataDir; + + DynamicUser = true; + User = "beszel-hub"; + LockPersonality = true; + NoNewPrivileges = true; + PrivateDevices = true; + PrivateTmp = true; + PrivateUsers = true; + ProtectClock = true; + ProtectControlGroups = "strict"; + ProtectHome = "read-only"; + ProtectHostname = true; + ProtectKernelLogs = true; + ProtectKernelModules = true; + ProtectKernelTunables = true; + ProtectSystem = "strict"; + DevicePolicy = "closed"; + Restart = "on-failure"; + RestartSec = "30s"; + RestrictRealtime = true; + RestrictSUIDSGID = true; + RestrictNamespaces = true; + SystemCallArchitectures = "native"; + SystemCallErrorNumber = "EPERM"; + SystemCallFilter = [ "@system-service" ]; + UMask = 27; + }; + }; + }; +}