1{
2 lib,
3 stdenv,
4 buildGoModule,
5 nodejs,
6 python3,
7 libtool,
8 npmHooks,
9 fetchFromGitHub,
10 fetchNpmDeps,
11 testers,
12 mailpit,
13 nixosTests,
14}:
15
16let
17 source = import ./source.nix;
18
19 inherit (source)
20 version
21 vendorHash
22 ;
23
24 src = fetchFromGitHub {
25 owner = "axllent";
26 repo = "mailpit";
27 rev = "v${version}";
28 hash = source.hash;
29 };
30
31 # Separate derivation, because if we mix this in buildGoModule, the separate
32 # go-modules build inherits specific attributes and fails. Getting that to
33 # work is hackier than just splitting the build.
34 ui = stdenv.mkDerivation {
35 pname = "mailpit-ui";
36 inherit src version;
37
38 npmDeps = fetchNpmDeps {
39 inherit src;
40 hash = source.npmDepsHash;
41 };
42
43 nativeBuildInputs = [
44 nodejs
45 python3
46 libtool
47 npmHooks.npmConfigHook
48 ];
49
50 buildPhase = ''
51 npm run package
52 '';
53
54 installPhase = ''
55 mv server/ui/dist $out
56 '';
57 };
58
59in
60
61buildGoModule {
62 pname = "mailpit";
63 inherit src version vendorHash;
64
65 env.CGO_ENABLED = 0;
66
67 ldflags = [
68 "-s"
69 "-w"
70 "-X github.com/axllent/mailpit/config.Version=${version}"
71 ];
72
73 preBuild = ''
74 cp -r ${ui} server/ui/dist
75 '';
76
77 passthru.tests = {
78 inherit (nixosTests) mailpit;
79 version = testers.testVersion {
80 package = mailpit;
81 command = "mailpit version";
82 };
83 };
84
85 passthru.updateScript = {
86 supportedFeatures = [ "commit" ];
87 command = ./update.sh;
88 };
89
90 meta = with lib; {
91 description = "Email and SMTP testing tool with API for developers";
92 homepage = "https://github.com/axllent/mailpit";
93 changelog = "https://github.com/axllent/mailpit/releases/tag/v${version}";
94 maintainers = with maintainers; [ stephank ];
95 license = licenses.mit;
96 mainProgram = "mailpit";
97 };
98}