From edaf77fda92056a17721acdacee0362716efb9ee Mon Sep 17 00:00:00 2001 From: Minijackson Date: Wed, 22 May 2024 10:43:49 +0200 Subject: [PATCH] nixos/phoebus-alarm-server: put config in /etc, install package useful for importing / exporting configs fixes #81 (cherry picked from commit cfd42087efb726757702421b0425183eaa23f2cd) --- nixos/modules/phoebus/alarm-server.nix | 11 +++++++++-- nixos/tests/phoebus/alarm.py | 5 +++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/nixos/modules/phoebus/alarm-server.nix b/nixos/modules/phoebus/alarm-server.nix index d7ed08f4..736fc0b2 100644 --- a/nixos/modules/phoebus/alarm-server.nix +++ b/nixos/modules/phoebus/alarm-server.nix @@ -8,6 +8,7 @@ cfg = config.services.phoebus-alarm-server; settingsFormat = pkgs.formats.javaProperties {}; configFile = settingsFormat.generate "phoebus-alarm-server.properties" cfg.settings; + configLocation = "phoebus/alarm-server.properties"; in { options.services.phoebus-alarm-server = { enable = lib.mkEnableOption '' @@ -159,6 +160,12 @@ in { } ]; + environment = { + etc."${configLocation}".source = configFile; + # Useful for importing alarm sets + systemPackages = [pkgs.epnix.phoebus-alarm-server]; + }; + systemd.services.phoebus-alarm-server = { description = "Phoebus Alarm Server"; @@ -171,10 +178,10 @@ in { args = [ "-noshell" - "-settings ${configFile}" + "-settings /etc/${configLocation}" ] ++ (lib.optional cfg.createTopics "-create_topics"); - in "${pkgs.epnix.phoebus-alarm-server}/bin/phoebus-alarm-server ${lib.concatStringsSep " " args}"; + in "${lib.getExe pkgs.epnix.phoebus-alarm-server} ${lib.concatStringsSep " " args}"; DynamicUser = true; StateDirectory = "phoebus-alarm-server"; # TODO: systemd hardening diff --git a/nixos/tests/phoebus/alarm.py b/nixos/tests/phoebus/alarm.py index c17125ef..e6212a96 100644 --- a/nixos/tests/phoebus/alarm.py +++ b/nixos/tests/phoebus/alarm.py @@ -190,3 +190,8 @@ def logger_has_latest_state(_): assert alarm_states[2]["current_severity"] == "MAJOR" assert alarm_states[2]["severity"] == "MAJOR" assert alarm_states[2]["value"] == "4.0" + +with subtest("Can export alarm configuration"): + server.succeed("phoebus-alarm-server -settings /etc/phoebus/alarm-server.properties -export export.xml") + server.succeed("grep ALARM_TEST export.xml") + server.copy_from_vm("export.xml")