added new command line interface

This commit is contained in:
2023-10-04 17:39:03 +02:00
parent cd758de656
commit 032e5a095c
3 changed files with 64 additions and 99 deletions

View File

@ -8,9 +8,6 @@ inputs: {
cfg = config.outage-detector;
package = inputs.self.packages.${pkgs.stdenv.hostPlatform.system}.default;
inherit (lib) mkIf mkEnableOption mkOption types;
format = pkgs.formats.json {};
configFile = format.generate "config.json" cfg.settings;
in {
options.outage-detector = {
enable = mkEnableOption "outage-detector";
@ -37,7 +34,11 @@ in {
]);
in
valueType;
default = throw "Please specify outage-detector.settings";
default = {
filename = throw "Please specify outage-detector.settings.";
host = "1.1.1.1";
timeout = 2;
};
};
};
@ -46,7 +47,7 @@ in {
systemd.services.outage-detector = mkIf (cfg.timer
!= null) {
script = "${package}/bin/outage_detector --config ${configFile}";
script = "${package}/bin/outage_detector log ${cfg.settings.filename} --host ${cfg.settings.host} --timeout ${cfg.settings.timeout}";
serviceConfig = {
Type = "oneshot";