From 4b224eefdd48c31812d78cada05936471b891f02 Mon Sep 17 00:00:00 2001 From: Arnout Engelen Date: Tue, 24 Mar 2026 13:11:33 +0100 Subject: [PATCH] nixos/autossh-ng: more accurate systemd unit readiness This is convenient e.g. if you have another process that wants to use the connection; that can wait for the unit to become ready instead of 'blindly' (re)trying the connection. --- nixos/modules/services/networking/autossh-ng.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nixos/modules/services/networking/autossh-ng.nix b/nixos/modules/services/networking/autossh-ng.nix index 3eca98b2e25d..c7f4f52ebaab 100644 --- a/nixos/modules/services/networking/autossh-ng.nix +++ b/nixos/modules/services/networking/autossh-ng.nix @@ -105,6 +105,8 @@ in wantedBy = [ "multi-user.target" ]; serviceConfig = { + Type = "notify"; + NotifyAccess = "all"; User = "${s.user}"; # backoff would be nice, but doesn't automatically # get reset on successful start yet, so static 10s restart for now: @@ -117,11 +119,16 @@ in "-o \"UserKnownHostsFile=${s.knownHostsFile}\"" else "-o \"UserKnownHostsFile=/dev/null\" -o \"StrictHostKeyChecking=no\""; + ready = pkgs.writers.writeBash "systemd-signal-ready" '' + ${pkgs.systemd}/bin/systemd-notify --ready + ''; in '' ${pkgs.openssh}/bin/ssh \ -o "ServerAliveInterval 30" \ -o "ServerAliveCountMax 3" \ + -o "PermitLocalCommand=yes" \ + -o "LocalCommand ${ready}" \ -o ExitOnForwardFailure=yes \ ${hostKeyCheckOption} \ -N \