diff options
| author | Rohit Singh <rsrohitsingh682@gmail.com> | 2024-10-03 23:42:10 +0530 |
|---|---|---|
| committer | Rohit Singh <rsrohitsingh682@gmail.com> | 2024-10-03 23:42:10 +0530 |
| commit | 239d802869a30bb45d4403e8f63a57a61f6910d9 (patch) | |
| tree | 2f0f35c64333b1c46839d95458dc388d756eb959 /modules | |
| parent | 76559183801030451e200c90a1627c1d82bb4910 (diff) | |
netdata: add netdata service in nix-darwin.
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/module-list.nix | 1 | ||||
| -rw-r--r-- | modules/services/monitoring/netdata.nix | 55 |
2 files changed, 56 insertions, 0 deletions
diff --git a/modules/module-list.nix b/modules/module-list.nix index 0b62158..c709964 100644 --- a/modules/module-list.nix +++ b/modules/module-list.nix @@ -69,6 +69,7 @@ ./services/mail/offlineimap.nix ./services/mopidy.nix ./services/monitoring/telegraf.nix + ./services/monitoring/netdata.nix ./services/netbird.nix ./services/nix-daemon.nix ./services/nix-gc diff --git a/modules/services/monitoring/netdata.nix b/modules/services/monitoring/netdata.nix new file mode 100644 index 0000000..da0809c --- /dev/null +++ b/modules/services/monitoring/netdata.nix @@ -0,0 +1,55 @@ +{ config, lib, pkgs, ... }: +with lib; +let + cfg = config.services.netdata; + +in { + meta.maintainers = [ lib.maintainers.rsrohitsingh682 or "rsrohitsingh682" ]; + + options = { + services.netdata = { + enable = mkEnableOption "Netdata daemon"; + + package = lib.mkPackageOption pkgs "netdata" {}; + + config = mkOption { + type = types.lines; + default = ""; + description = "Custom configuration for Netdata"; + }; + + workDir = mkOption { + type = types.path; + default = "/var/lib/netdata"; + description = "Working directory for Netdata"; + }; + + logDir = mkOption { + type = types.path; + default = "/var/log/netdata"; + description = "Log directory for Netdata"; + }; + }; + }; + + config = mkIf cfg.enable { + environment.systemPackages = [ cfg.package ]; + + launchd.daemons.netdata = { + serviceConfig = { + Label = "netdata"; + KeepAlive = true; + WorkingDirectory = cfg.workDir; + StandardErrorPath = "${cfg.logDir}/netdata.log"; + StandardOutPath = "${cfg.logDir}/netdata.log"; + }; + command = lib.getExe cfg.package; + }; + + environment.etc."netdata/netdata.conf".text = cfg.config; + + system.activationScripts.preActivation.text = '' + mkdir -p ${cfg.workDir} + ''; + }; +} |
