mailpit: fix build by splitting off nodejs part

This commit is contained in:
Stéphan Kochen 2023-07-12 13:15:34 +02:00
parent d857b1261c
commit 8a072bf42f

View file

@ -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";