From 8bf0e13e03ff11170c527e1d5cd0a0f5d588863b Mon Sep 17 00:00:00 2001 From: Minijackson Date: Thu, 23 May 2024 09:55:57 +0200 Subject: [PATCH 1/2] phoebus-alarm-server: set meta.mainProgram (cherry picked from commit 6d90961082771f80cfa55394cde9056c5f43ffdb) --- pkgs/epnix/tools/phoebus/alarm-server/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/epnix/tools/phoebus/alarm-server/default.nix b/pkgs/epnix/tools/phoebus/alarm-server/default.nix index 1563c8c1..9213422d 100644 --- a/pkgs/epnix/tools/phoebus/alarm-server/default.nix +++ b/pkgs/epnix/tools/phoebus/alarm-server/default.nix @@ -53,6 +53,7 @@ in meta = { description = "Monitor a configurable set of PVs and track their alarm state"; homepage = "https://control-system-studio.readthedocs.io/en/latest/services/alarm-server/doc/index.html"; + mainProgram = "phoebus-alarm-server"; license = lib.licenses.epl10; maintainers = with epnixLib.maintainers; [minijackson]; inherit (jdk.meta) platforms; From 145893beea92ba43d32ee16b046d2dffdd8dd74c Mon Sep 17 00:00:00 2001 From: Minijackson Date: Wed, 22 May 2024 10:43:49 +0200 Subject: [PATCH 2/2] 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 2345f1a0..b1aede60 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 '' @@ -161,6 +162,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"; @@ -173,10 +180,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")