1{ lib, buildGoModule, fetchFromGitHub, pam, coreutils, installShellFiles, scdoc, nixosTests }:
2
3buildGoModule rec {
4 pname = "maddy";
5 version = "0.7.0";
6
7 src = fetchFromGitHub {
8 owner = "foxcpp";
9 repo = "maddy";
10 rev = "v${version}";
11 sha256 = "sha256-EMw07yTFP0aBSuGDWivB8amuxWLFHhYV6J9faTEW5z4=";
12 };
13
14 vendorSha256 = "sha256-LyfkETZPkhJKN8CEivNp7Se4IBpzyAtmCM1xil4n2po=";
15
16 tags = [ "libpam" ];
17
18 ldflags = [ "-s" "-w" "-X github.com/foxcpp/maddy.Version=${version}" ];
19
20 subPackages = [ "cmd/maddy" ];
21
22 buildInputs = [ pam ];
23
24 nativeBuildInputs = [ installShellFiles scdoc ];
25
26 postInstall = ''
27 for f in docs/man/*.scd; do
28 local page="docs/man/$(basename "$f" .scd)"
29 scdoc < "$f" > "$page"
30 installManPage "$page"
31 done
32
33 ln -s "$out/bin/maddy" "$out/bin/maddyctl"
34
35 mkdir -p $out/lib/systemd/system
36
37 substitute dist/systemd/maddy.service $out/lib/systemd/system/maddy.service \
38 --replace "/usr/local/bin/maddy" "$out/bin/maddy" \
39 --replace "/bin/kill" "${coreutils}/bin/kill"
40
41 substitute dist/systemd/maddy@.service $out/lib/systemd/system/maddy@.service \
42 --replace "/usr/local/bin/maddy" "$out/bin/maddy" \
43 --replace "/bin/kill" "${coreutils}/bin/kill"
44 '';
45
46 passthru.tests.nixos = nixosTests.maddy;
47
48 meta = with lib; {
49 description = "Composable all-in-one mail server";
50 homepage = "https://maddy.email";
51 license = licenses.gpl3Plus;
52 maintainers = with maintainers; [ nickcao ];
53 };
54}