From 804533cde06189bb2109c063092d59b2d53ee4db Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 16 Mar 2025 17:15:39 +0100 Subject: ... --- accounts/gkleen@sif/systemd.nix | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) (limited to 'accounts/gkleen@sif/systemd.nix') diff --git a/accounts/gkleen@sif/systemd.nix b/accounts/gkleen@sif/systemd.nix index a89b46c2..14669a1e 100644 --- a/accounts/gkleen@sif/systemd.nix +++ b/accounts/gkleen@sif/systemd.nix @@ -6,7 +6,7 @@ let cfg = config.home-manager.users.${userName}; autossh-socks-script = pkgs.writeScript "autossh" '' - #!${pkgs.zsh}/bin/zsh -xe + #!${lib.getExe pkgs.zsh} -xe host="''${1%:*}" port="''${1#*:}" @@ -15,31 +15,29 @@ let cmd=() if [[ -n "''${SSHPASS_SECRET}" ]]; then - cmd+=(${pkgs.sshpassSecret}/bin/sshpass-secret) + cmd+=(${lib.getExe' pkgs.sshpassSecret "sshpass-secret"}) cmd+=("''${(@s/:/)SSHPASS_SECRET}") cmd+=(--) fi - cmd+=(${pkgs.openssh}/bin/ssh -vN -D localhost:''${port} "''${host}") + cmd+=(${lib.getExe' pkgs.openssh "ssh"} -vN -D localhost:''${port} "''${host}") ( exec -a "''${cmd[1]}" -- ''${cmd} ) & pid=$! newpid="" i=200 - while ! newpid=$(${pkgs.lsof}/bin/lsof -Pi @localhost:"''${port}" -sTCP:LISTEN -t); do + while ! newpid=$(${lib.getExe pkgs.lsof} -Pi @localhost:"''${port}" -sTCP:LISTEN -t); do if ! kill -0 "''${pid}"; then wait "''${pid}" exit $? fi [[ "''${i}" -gt 0 ]] || exit 1 i=$((''${i} - 1)) - ${pkgs.coreutils}/bin/sleep 0.1 + ${lib.getExe' pkgs.coreutils "sleep"} 0.1 done - ${config.systemd.package}/bin/systemd-notify --ready - - wait "''${pid}" "''${newpid}" + ${lib.getExe' config.systemd.package "systemd-notify"} --pid=''${newpid} --ready ''; in { tmpfiles.rules = [ @@ -146,7 +144,7 @@ in { Service.ExecStart = "${pkgs.bluez}/bin/mpris-proxy"; Install.WantedBy = [ "default.target" ]; }; - "autossh-socks@proxy.mathw0h:8119" = { + "autossh-socks@proxy.ssh.math.lmu.de:8119" = { Service = { Type = "notify"; NotifyAccess = "all"; @@ -154,7 +152,7 @@ in { Restart = "always"; RestartSec = "23s"; ExecStart = "${autossh-socks-script} \"%I\""; - Environment = [ "SSHPASS_SECRET=gkleen@mathw0g.math.lmu.de" ]; + Environment = [ "SSHPASS_SECRET=gkleen@ssh.math.lmu.de" ]; }; Unit = { StopWhenUnneeded = true; @@ -175,6 +173,22 @@ in { StopWhenUnneeded = true; }; }; + "autossh-socks@proxy.mathw0h:8123" = { + Service = { + Type = "notify"; + NotifyAccess = "all"; + WorkingDirectory = "~"; + Restart = "always"; + RestartSec = "23s"; + ExecStart = "${autossh-socks-script} \"%I\""; + Environment = [ "SSHPASS_SECRET=gkleen@mathw0h.mathinst.loc" ]; + }; + Unit = { + StopWhenUnneeded = true; + StartLimitInterval = "180s"; + StartLimitBurst = 7; + }; + }; swayidle = { Service = { RuntimeDirectory = "swayidle"; @@ -356,7 +370,7 @@ in { Service = { ExecStart = "${config.systemd.package}/lib/systemd/systemd-socket-proxyd --exit-idle-time=10s localhost:${toString (port + 1)}"; }; - }) [{ host = "proxy.mathw0h"; port = 8118; } { host = "proxy.vidhar"; port = 8120; }]); + }) [{ host = "proxy.ssh.math.lmu.de"; port = 8118; } { host = "proxy.vidhar"; port = 8120; } { host = "proxy.mathw0h"; port = 8122; }]); sockets = listToAttrs (map (port: nameValuePair "proxy-to-autossh-socks@${toString port}" { Socket = { ListenStream = "%I"; @@ -364,7 +378,7 @@ in { Install = { WantedBy = ["default.target"]; }; - }) [8118 8120]) // { + }) [8118 8120 8122]) // { "yt-dlp" = { Socket = { SocketMode = "0600"; -- cgit v1.2.3