ConditionPathExists can't use env vars.
Use a separate watch job instead.
This commit is contained in:
parent
9a97eb1de7
commit
a52626e237
51
module.nix
51
module.nix
|
@ -53,26 +53,39 @@ in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
nixpkgs.overlays = [ wallfly-overlay ];
|
nixpkgs.overlays = [ wallfly-overlay ];
|
||||||
|
|
||||||
systemd.user.services.wallfly = {
|
systemd.user.services = {
|
||||||
wantedBy = [ "graphical-session.target" ];
|
wallfly-password-watcher = {
|
||||||
after = [ "graphical-session.target" ];
|
requiredBy = [ "wallfly.service" ];
|
||||||
requires = [ "graphical-session.target" ];
|
before = [ "wallfly.service" ];
|
||||||
path = with pkgs; [ nettools xprintidle ];
|
restartIfChanged = true;
|
||||||
restartIfChanged = true;
|
serviceConfig = {
|
||||||
serviceConfig = {
|
TimeoutStartSec = 180;
|
||||||
ExecStart = pkgs.writeShellScript "launch-wallfly.sh" ''
|
ExecStart = pkgs.writeShellScript "watch-wallfly-passwd.sh" ''
|
||||||
${pkgs.wallfly}/bin/wallfly \
|
test -f ${cfg.mqtt.password-file} && sleep 3
|
||||||
--location=${cfg.location} \
|
exit 0
|
||||||
--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} \
|
wallfly = {
|
||||||
--delay-time=${toString cfg.delay-time}
|
wantedBy = [ "graphical-session.target" ];
|
||||||
'';
|
after = [ "graphical-session.target" ];
|
||||||
Restart = "always";
|
requires = [ "graphical-session.target" ];
|
||||||
StandardOutput = "journal";
|
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 ];
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue