From 561e7b61c36502ba7ed36089477b4e3469beff60 Mon Sep 17 00:00:00 2001 From: Cole Helbling Date: Fri, 27 Oct 2023 07:28:11 -0700 Subject: [PATCH] flake: fix systemd service by hardcoding $PORT Another solution would be to copy the `.defaults` file alongside the service file, and set the `EnvironmentFile` to point to that, but it would still be hardcoded (as the `.defaults` file would be stored in the Nix store), so I figured that this is a good solution until there is a proper NixOS module. Fixes #9995. Signed-off-by: Cole Helbling --- flake.nix | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 01c17690d..f3cca83eb 100644 --- a/flake.nix +++ b/flake.nix @@ -72,11 +72,23 @@ CGO_ENABLED = 0; subPackages = [ "cmd/tailscale" "cmd/tailscaled" ]; doCheck = false; + + # NOTE: We strip the ${PORT} and $FLAGS because they are unset in the + # environment and cause issues (specifically the unset PORT). At some + # point, there should be a NixOS module that allows configuration of these + # things, but for now, we hardcode the default of port 41641 (taken from + # ./cmd/tailscaled/tailscaled.defaults). postInstall = pkgs.lib.optionalString pkgs.stdenv.isLinux '' wrapProgram $out/bin/tailscaled --prefix PATH : ${pkgs.lib.makeBinPath [ pkgs.iproute2 pkgs.iptables pkgs.getent pkgs.shadow ]} wrapProgram $out/bin/tailscale --suffix PATH : ${pkgs.lib.makeBinPath [ pkgs.procps ]} - sed -i -e "s#/usr/sbin#$out/bin#" -e "/^EnvironmentFile/d" ./cmd/tailscaled/tailscaled.service + sed -i \ + -e "s#/usr/sbin#$out/bin#" \ + -e "/^EnvironmentFile/d" \ + -e 's/''${PORT}/41641/' \ + -e 's/$FLAGS//' \ + ./cmd/tailscaled/tailscaled.service + install -D -m0444 -t $out/lib/systemd/system ./cmd/tailscaled/tailscaled.service ''; };