diff --git a/hosts/temmie/services/userweb.nix b/hosts/temmie/services/userweb.nix index fd3d679..418b95a 100644 --- a/hosts/temmie/services/userweb.nix +++ b/hosts/temmie/services/userweb.nix @@ -64,6 +64,21 @@ let ignoreCollisions = true; }; + sendmailWrapper = pkgs.writeShellApplication { + name = "sendmail"; + runtimeInputs = [ ]; + text = '' + args=("$@") + + if [[ "''${PWD:-}" =~ ^/home/pvv/[^/]+/([^/]+) ]] && [[ "''${BASH_REMATCH[1]}" != "pvv" ]]; then + # Prepend -fusername to the argument list, so bounces go to the user + args=("-f''${BASH_REMATCH[1]}" "''${args[@]}") + fi + + exec '${lib.getExe pkgs.system-sendmail}' "''${args[@]}" + ''; + }; + # https://nixos.org/manual/nixpkgs/stable/#sec-building-environment fhsEnv = pkgs.buildEnv { name = "userweb-env"; @@ -71,6 +86,8 @@ let paths = with pkgs; [ bash + sendmailWrapper + perlEnv pythonEnv phpEnv