nixpkgs/pkgs/servers/mail/mailpit/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

83 lines
2.0 KiB
Nix
Raw Normal View History

2023-07-11 11:41:23 +00:00
{ lib
, stdenv
2023-07-11 11:41:23 +00:00
, buildGoModule
, nodejs
, python3
, libtool
, npmHooks
, fetchFromGitHub
, fetchNpmDeps
2023-11-13 09:09:54 +00:00
, testers
, mailpit
2023-07-11 11:41:23 +00:00
}:
let
2024-04-05 04:40:22 +00:00
version = "1.15.1";
2023-07-11 11:41:23 +00:00
src = fetchFromGitHub {
owner = "axllent";
repo = "mailpit";
rev = "v${version}";
2024-04-05 04:40:22 +00:00
hash = "sha256-5QEn4sEZgtoFrVonZsAtvzhEkxYGDEWwhJOxqwWQJTk=";
2023-07-11 11:41:23 +00:00
};
# 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;
2024-03-21 09:27:52 +00:00
hash = "sha256-5F68ia2V8mw4iPAjSoz0b8z1lplWtAg98BgDXYOmMKs=";
};
2023-07-11 11:41:23 +00:00
2023-11-17 04:20:00 +00:00
env = lib.optionalAttrs (stdenv.isDarwin && stdenv.isx86_64) {
# Make sure libc++ uses `posix_memalign` instead of `aligned_alloc` on x86_64-darwin.
# Otherwise, nodejs would require the 11.0 SDK and macOS 10.15+.
NIX_CFLAGS_COMPILE = "-D__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__=101300";
};
nativeBuildInputs = [ nodejs python3 libtool npmHooks.npmConfigHook ];
buildPhase = ''
npm run package
'';
installPhase = ''
mv server/ui/dist $out
'';
2023-07-11 11:41:23 +00:00
};
in
2023-07-11 11:41:23 +00:00
buildGoModule {
pname = "mailpit";
inherit src version;
2024-03-21 09:27:52 +00:00
vendorHash = "sha256-e2mlOwGDU5NlKZSstHMdTidSfhNeeY6cBgtW+W9nwV8=";
2023-07-11 11:41:23 +00:00
CGO_ENABLED = 0;
ldflags = [ "-s" "-w" "-X github.com/axllent/mailpit/config.Version=${version}" ];
preBuild = ''
cp -r ${ui} server/ui/dist
'';
2023-11-13 09:09:54 +00:00
passthru.tests.version = testers.testVersion {
package = mailpit;
command = "mailpit version";
};
2023-07-11 11:41:23 +00:00
meta = with lib; {
description = "An email and SMTP testing tool with API for developers";
homepage = "https://github.com/axllent/mailpit";
changelog = "https://github.com/axllent/mailpit/releases/tag/v${version}";
maintainers = with maintainers; [ stephank ];
license = licenses.mit;
2023-10-30 04:20:00 +00:00
mainProgram = "mailpit";
2023-07-11 11:41:23 +00:00
};
}