ConditionPathExists can't use env vars.

Use a separate watch job instead.
This commit is contained in:
niten 2023-09-26 13:13:22 -07:00
parent 9a97eb1de7
commit a52626e237
1 changed files with 32 additions and 19 deletions

View File

@ -53,26 +53,39 @@ in {
config = mkIf cfg.enable {
nixpkgs.overlays = [ wallfly-overlay ];
systemd.user.services.wallfly = {
wantedBy = [ "graphical-session.target" ];
after = [ "graphical-session.target" ];
requires = [ "graphical-session.target" ];
path = with pkgs; [ nettools xprintidle ];
restartIfChanged = true;
serviceConfig = {
ExecStart = pkgs.writeShellScript "launch-wallfly.sh" ''
${pkgs.wallfly}/bin/wallfly \
--location=${cfg.location} \
--mqtt-broker-uri=${cfg.mqtt.broker-uri} \
--mqtt-username=${cfg.mqtt.username} \
--mqtt-password-file=${cfg.mqtt.password-file} \
--time-to-idle=${toString cfg.time-to-idle} \
--delay-time=${toString cfg.delay-time}
'';
Restart = "always";
StandardOutput = "journal";
systemd.user.services = {
wallfly-password-watcher = {
requiredBy = [ "wallfly.service" ];
before = [ "wallfly.service" ];
restartIfChanged = true;
serviceConfig = {
TimeoutStartSec = 180;
ExecStart = pkgs.writeShellScript "watch-wallfly-passwd.sh" ''
test -f ${cfg.mqtt.password-file} && sleep 3
exit 0
'';
};
};
wallfly = {
wantedBy = [ "graphical-session.target" ];
after = [ "graphical-session.target" ];
requires = [ "graphical-session.target" ];
path = with pkgs; [ nettools xprintidle ];
restartIfChanged = true;
serviceConfig = {
ExecStart = pkgs.writeShellScript "launch-wallfly.sh" ''
${pkgs.wallfly}/bin/wallfly \
--location=${cfg.location} \
--mqtt-broker-uri=${cfg.mqtt.broker-uri} \
--mqtt-username=${cfg.mqtt.username} \
--mqtt-password-file=${cfg.mqtt.password-file} \
--time-to-idle=${toString cfg.time-to-idle} \
--delay-time=${toString cfg.delay-time}
'';
Restart = "always";
StandardOutput = "journal";
};
};
unitConfig.ConditionPathExists = [ cfg.mqtt.password-file ];
};
};
}