From 8a072bf42fb94c8ac2a9bb4e159e2e3ae2cb6948 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phan=20Kochen?= Date: Wed, 12 Jul 2023 13:15:34 +0200 Subject: [PATCH] mailpit: fix build by splitting off nodejs part --- pkgs/servers/mail/mailpit/default.nix | 43 ++++++++++++++++++++------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/pkgs/servers/mail/mailpit/default.nix b/pkgs/servers/mail/mailpit/default.nix index aa7a21371180..9c8b683373c3 100644 --- a/pkgs/servers/mail/mailpit/default.nix +++ b/pkgs/servers/mail/mailpit/default.nix @@ -1,4 +1,5 @@ { lib +, stdenv , buildGoModule , nodejs , python3 @@ -8,8 +9,8 @@ , fetchNpmDeps }: -buildGoModule rec { - pname = "mailpit"; +let + version = "1.7.1"; src = fetchFromGitHub { @@ -19,23 +20,45 @@ buildGoModule rec { hash = "sha256-jT9QE0ikp9cJlT8qtfPPjKOUuqWyQk94D3UbkyaGXa8="; }; - vendorHash = "sha256-XBYIO7fdo5EahJB7EcAuY9SGKZb8dsvoJHp/D5LO5Qo="; + # Separate derivation, because if we mix this in buildGoModule, the separate + # go-modules build inherits specific attributes and fails. Getting that to + # work is hackier than just splitting the build. + ui = stdenv.mkDerivation { + pname = "mailpit-ui"; + inherit src version; - npmDeps = fetchNpmDeps { - inherit src; - hash = "sha256-6VCs8125fTJkZW+eZgK56j7ccK8tcGhIXiq2HkYp4XM="; + npmDeps = fetchNpmDeps { + inherit src; + hash = "sha256-6VCs8125fTJkZW+eZgK56j7ccK8tcGhIXiq2HkYp4XM="; + }; + + nativeBuildInputs = [ nodejs python3 libtool npmHooks.npmConfigHook ]; + + buildPhase = '' + npm run package + ''; + + installPhase = '' + mv server/ui/dist $out + ''; }; - nativeBuildInputs = [ nodejs python3 libtool npmHooks.npmConfigHook ]; +in - preBuild = '' - npm run package - ''; +buildGoModule { + pname = "mailpit"; + inherit src version; + + vendorHash = "sha256-XBYIO7fdo5EahJB7EcAuY9SGKZb8dsvoJHp/D5LO5Qo="; CGO_ENABLED = 0; ldflags = [ "-s" "-w" "-X github.com/axllent/mailpit/config.Version=${version}" ]; + preBuild = '' + cp -r ${ui} server/ui/dist + ''; + meta = with lib; { description = "An email and SMTP testing tool with API for developers"; homepage = "https://github.com/axllent/mailpit";