From 6d90961082771f80cfa55394cde9056c5f43ffdb 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 --- 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 cfd42087efb726757702421b0425183eaa23f2cd 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 --- 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")