Skip to content

Commit

Permalink
nixos/phoebus-alarm-server: put config in /etc, install package
Browse files Browse the repository at this point in the history
useful for importing / exporting configs

fixes #81
  • Loading branch information
minijackson committed May 23, 2024
1 parent 50934b3 commit 320267b
Show file tree
Hide file tree
Showing 2 changed files with 13 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
4 changes: 4 additions & 0 deletions nixos/tests/phoebus/alarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,7 @@ 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 -config /etc/phoebus/alarm-server.properties -export export.xml")
server.copy_from_vm("export.xml")

0 comments on commit 320267b

Please sign in to comment.