Skip to content

Commit

Permalink
Merge pull request #82 from minijackson/phoebus-alarm-link
Browse files Browse the repository at this point in the history
nixos/phoebus-alarm-server: put config in /etc, install package
  • Loading branch information
minijackson committed Jun 6, 2024
2 parents 08983e1 + cfd4208 commit 05d8040
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
11 changes: 9 additions & 2 deletions nixos/modules/phoebus/alarm-server.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 ''
Expand Down Expand Up @@ -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";

Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions nixos/tests/phoebus/alarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
1 change: 1 addition & 0 deletions pkgs/epnix/tools/phoebus/alarm-server/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 05d8040

Please sign in to comment.