diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index 8483c23a6a1dd..ba68dc8ae8cbd 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -18650,6 +18650,11 @@ githubId = 47303199; name = "Simon Gutgesell"; }; + non-bin = { + name = "Alice Jacka"; + github = "non-bin"; + githubId = 36313060; + }; noodlez1232 = { email = "contact@nathanielbarragan.xyz"; matrix = "@noodlez1232:matrix.org"; diff --git a/nixos/doc/manual/release-notes/rl-2511.section.md b/nixos/doc/manual/release-notes/rl-2511.section.md index 84b418a5db934..568e6853c1fa8 100644 --- a/nixos/doc/manual/release-notes/rl-2511.section.md +++ b/nixos/doc/manual/release-notes/rl-2511.section.md @@ -116,6 +116,8 @@ - [paisa](https://github.com/ananthakumaran/paisa), a personal finance tracker and dashboard. Available as [services.paisa](#opt-services.paisa.enable). +- [beszel](https://github.com/henrygd/beszel), Lightweight server monitoring hub with historical data, docker stats, and alerts. Available as [services.beszel.agent](#opt-services.beszel.agent.enable) and [services.beszel.hub](#opt-services.beszel.hub.enable). + - [conman](https://github.com/dun/conman), a serial console management program. Available as [services.conman](#opt-services.conman.enable). - [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). diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 7f1eb380cd407..50d5989af6be6 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -967,6 +967,7 @@ ./services/monitoring/apcupsd.nix ./services/monitoring/arbtt.nix ./services/monitoring/below.nix + ./services/monitoring/beszel.nix ./services/monitoring/bosun.nix ./services/monitoring/cadvisor.nix ./services/monitoring/certspotter.nix diff --git a/nixos/modules/services/monitoring/beszel.nix b/nixos/modules/services/monitoring/beszel.nix new file mode 100644 index 0000000000000..a0e003713e384 --- /dev/null +++ b/nixos/modules/services/monitoring/beszel.nix @@ -0,0 +1,81 @@ +{ + config, + lib, + pkgs, + ... +}: +let + cfg = config.services.beszel; +in +{ + meta.maintainers = [ lib.maintainers.non-bin ]; + + options.services.beszel = { + agent = { + enable = lib.mkEnableOption "agent"; + key = lib.mkOption { + type = lib.types.str; + description = "Public key(s) for SSH authentication"; + example = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGBvkz0O6T8dzn1yJTkj3wOSu/7IehuxVPSM5tKzsx5x"; + }; + listen = lib.mkOption { + type = lib.types.str; + default = "0.0.0.0:45876"; + description = "Address and port to listen on"; + example = "127.0.0.1:3265"; + }; + }; + + hub = { + enable = lib.mkEnableOption "hub"; + httpListen = lib.mkOption { + type = lib.types.str; + default = "0.0.0.0:80"; + description = "Address and port to listen for http traffic"; + example = "192.168.0.4:8090"; + }; + httpsListen = lib.mkOption { + type = lib.types.str; + default = ""; + description = "Address and port to listen for https traffic. If specified, http traffic will be redirected to https"; + example = "0.0.0.0:443"; + }; + domains = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = [ ]; + description = "Domains to listen on. If specified, http traffic will be redirected to https, and httpsListen will default to `0.0.0.0:443`"; + example = [ "example.com" ]; + }; + }; + }; + + config = { + environment.systemPackages = lib.mkIf (cfg.agent.enable || cfg.hub.enable) [ pkgs.beszel ]; + + systemd.services = { + beszel-agent = lib.mkIf cfg.agent.enable { + description = "Beszel Monitoring System monitoring agent"; + wantedBy = [ "multi-user.target" ]; + after = [ "networking.target" ]; + serviceConfig = { + ExecStart = ''${pkgs.beszel}/bin/beszel-agent -key "${cfg.agent.key}" -listen "${cfg.agent.listen}"''; + }; + }; + + beszel-hub = lib.mkIf cfg.hub.enable { + description = "Beszel Monitoring System hub server"; + wantedBy = [ "multi-user.target" ]; + after = [ "networking.target" ]; + serviceConfig = { + ExecStart = ''${pkgs.beszel}/bin/beszel-hub serve ${ + if ((lib.length cfg.hub.domains) > 0) then + (''"'' + (lib.concatStringsSep ''" "'' cfg.hub.domains) + ''"'') + else + "" + } --http "${cfg.hub.httpListen}" --https "${cfg.hub.httpsListen}"''; + WorkingDirectory = "/var/db/beszel"; + }; + }; + }; + }; +}