From 5964601a116024f501c8e8f783b8e6281d279828 Mon Sep 17 00:00:00 2001 From: lewis Date: Tue, 10 Feb 2026 20:22:08 +0200 Subject: [PATCH] fix: set env vars of paths for sendmail & signal from nix pkg not manual --- module.nix | 24 +++++++++--------------- test.nix | 26 +++++++++++++------------- 2 files changed, 22 insertions(+), 28 deletions(-) diff --git a/module.nix b/module.nix index 3d26657..a2c1e06 100644 --- a/module.nix +++ b/module.nix @@ -149,8 +149,8 @@ in }; SENDMAIL_PATH = mkOption { - type = types.nullOr types.path; - default = null; + type = types.path; + default = lib.getExe pkgs.system-sendmail; description = "Path to the sendmail executable to use for sending emails."; }; @@ -161,8 +161,8 @@ in }; SIGNAL_CLI_PATH = mkOption { - type = types.nullOr types.path; - default = null; + type = types.path; + default = lib.getExe pkgs.signal-cli; description = "Path to the signal-cli executable to use for sending Signal notifications."; }; @@ -309,16 +309,6 @@ in }) { - services.tranquil-pds.settings = { - SENDMAIL_PATH = lib.mkDefault ( - if cfg.settings.MAIL_FROM_ADDRESS != null then (lib.getExe pkgs.system-sendmail) else null - ); - - SIGNAL_CLI_PATH = lib.mkDefault ( - if cfg.settings.SIGNAL_SENDER_NUMBER != null then (lib.getExe pkgs.signal-cli) else null - ); - }; - users.users.${cfg.user} = { isSystemUser = true; inherit (cfg) group; @@ -359,7 +349,11 @@ in EnvironmentFile = cfg.environmentFiles; Environment = lib.mapAttrsToList (k: v: "${k}=${if builtins.isInt v then toString v else v}") ( - lib.filterAttrs (_: v: v != null) cfg.settings + lib.filterAttrs (k: v: + if k == "SENDMAIL_PATH" then cfg.settings.MAIL_FROM_ADDRESS != null + else if k == "SIGNAL_CLI_PATH" then cfg.settings.SIGNAL_SENDER_NUMBER != null + else v != null + ) cfg.settings ); NoNewPrivileges = true; diff --git a/test.nix b/test.nix index d6f4b0b..9899bac 100644 --- a/test.nix +++ b/test.nix @@ -23,7 +23,7 @@ pkgs.testers.nixosTest { }; settings = { - PDS_HOSTNAME = "test.local"; + PDS_HOSTNAME = "pds.test"; SERVER_HOST = "0.0.0.0"; DISABLE_RATE_LIMITING = 1; @@ -46,7 +46,7 @@ pkgs.testers.nixosTest { server.wait_for_open_port(80) def xrpc(method, endpoint, *, headers=None, data=None, raw_body=None, via="nginx"): - host_header = "-H 'Host: test.local'" if via == "nginx" else "" + host_header = "-H 'Host: pds.test'" if via == "nginx" else "" base = "http://localhost" if via == "nginx" else "http://localhost:3000" url = f"{base}/xrpc/{endpoint}" @@ -66,7 +66,7 @@ pkgs.testers.nixosTest { return json.loads(xrpc(method, endpoint, **kwargs)) def xrpc_status(endpoint, *, headers=None, via="nginx"): - host_header = "-H 'Host: test.local'" if via == "nginx" else "" + host_header = "-H 'Host: pds.test'" if via == "nginx" else "" base = "http://localhost" if via == "nginx" else "http://localhost:3000" url = f"{base}/xrpc/{endpoint}" @@ -77,18 +77,18 @@ pkgs.testers.nixosTest { return server.succeed(" ".join(parts)).strip() - def http_status(path, *, host="test.local", via="nginx"): + def http_status(path, *, host="pds.test", via="nginx"): base = "http://localhost" if via == "nginx" else "http://localhost:3000" return server.succeed( f"curl -s -o /dev/null -w '%{{http_code}}' -H 'Host: {host}' '{base}{path}'" ).strip() - def http_get(path, *, host="test.local"): + def http_get(path, *, host="pds.test"): return server.succeed( f"curl -sf -H 'Host: {host}' 'http://localhost{path}'" ) - def http_header(path, header, *, host="test.local"): + def http_header(path, header, *, host="pds.test"): return server.succeed( f"curl -sI -H 'Host: {host}' 'http://localhost{path}'" f" | grep -i '^{header}:'" @@ -120,7 +120,7 @@ pkgs.testers.nixosTest { assert desc.get("inviteCodeRequired") == False with subtest("nginx serves frontend"): - result = server.succeed("curl -sf -H 'Host: test.local' http://localhost/") + result = server.succeed("curl -sf -H 'Host: pds.test' http://localhost/") assert "