Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport nixos-23.05] nixos/phoebus-alarm-server: put config in /etc, install package #102

Merged
merged 2 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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";

Expand All @@ -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
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