diff --git a/nixos/modules/services/monitoring/glpi-agent.nix b/nixos/modules/services/monitoring/glpi-agent.nix new file mode 100644 index 00000000000000..14ab2a70229410 --- /dev/null +++ b/nixos/modules/services/monitoring/glpi-agent.nix @@ -0,0 +1,62 @@ +{ + config, + lib, + pkgs, + ... +}: + +let + cfg = config.services.glpiAgent; + + configFile = pkgs.writeText "agent.cfg" '' + # Server configuration + server = ${lib.concatStringsSep ", " cfg.servers} + + # Configuration + ${cfg.extraConfig} + ''; + +in +{ + options = { + services.glpiAgent = { + enable = lib.mkEnableOption "GLPI Agent"; + + package = lib.mkPackageOption pkgs "glpi-agent" { + }; + + servers = lib.mkOption { + type = lib.types.listOf lib.types.str; + example = [ "https://glpi.example.com/inventory" ]; + }; + + extraConfig = lib.mkOption { + type = lib.types.lines; + default = ""; + example = '' + delaytime = 3600 + timeout = 180 + tag = mytag + logger = stderr + ''; + }; + }; + }; + + config = lib.mkIf cfg.enable { + systemd.services.glpi-agent = { + description = "GLPI Agent"; + wantedBy = [ "multi-user.target" ]; + after = [ "network.target" ]; + + serviceConfig = { + ExecStart = "${lib.getExe cfg.package} --conf-file ${configFile} --vardir /var/lib/glpi-agent --daemon --no-fork"; + User = "root"; + Restart = "on-failure"; + StateDirectory = "glpi-agent"; + RuntimeDirectory = "glpi-agent"; + WorkingDirectory = "/var/lib/glpi-agent"; + }; + }; + }; +}