1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2024-12-14 11:57:34 +00:00

netdata: add netdata service in nix-darwin.

This commit is contained in:
Rohit Singh 2024-10-03 23:42:10 +05:30
parent 7655918380
commit 239d802869
4 changed files with 76 additions and 0 deletions

View file

@ -69,6 +69,7 @@
./services/mail/offlineimap.nix ./services/mail/offlineimap.nix
./services/mopidy.nix ./services/mopidy.nix
./services/monitoring/telegraf.nix ./services/monitoring/telegraf.nix
./services/monitoring/netdata.nix
./services/netbird.nix ./services/netbird.nix
./services/nix-daemon.nix ./services/nix-daemon.nix
./services/nix-gc ./services/nix-gc

View file

@ -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}
'';
};
}

View file

@ -128,6 +128,7 @@ let
tests.services-nix-gc = makeTest ./tests/services-nix-gc.nix; tests.services-nix-gc = makeTest ./tests/services-nix-gc.nix;
tests.services-nix-optimise = makeTest ./tests/services-nix-optimise.nix; tests.services-nix-optimise = makeTest ./tests/services-nix-optimise.nix;
tests.services-nextdns = makeTest ./tests/services-nextdns.nix; tests.services-nextdns = makeTest ./tests/services-nextdns.nix;
tests.services-netdata = makeTest ./tests/services-netdata.nix;
tests.services-ofborg = makeTest ./tests/services-ofborg.nix; tests.services-ofborg = makeTest ./tests/services-ofborg.nix;
tests.services-offlineimap = makeTest ./tests/services-offlineimap.nix; tests.services-offlineimap = makeTest ./tests/services-offlineimap.nix;
tests.services-privoxy = makeTest ./tests/services-privoxy.nix; tests.services-privoxy = makeTest ./tests/services-privoxy.nix;

View file

@ -0,0 +1,19 @@
{ config, lib, pkgs, ... }:
with lib;
let
netdata = pkgs.runCommand "netdata-0.0.0" {} "mkdir $out";
in
{
services.netdata = {
enable = true;
package = netdata;
};
test = ''
echo >&2 "checking netdata service in launchd daemons"
grep "netdata" ${config.out}/Library/LaunchDaemons/netdata.plist
grep "${netdata}/bin/netdata" ${config.out}/Library/LaunchDaemons/netdata.plist
'';
}