1{
2 lib,
3 beamPackages,
4 fetchFromGitHub,
5 fetchFromGitLab,
6 fetchHex,
7 file,
8 cmake,
9 nixosTests,
10 writeText,
11 vips,
12 pkg-config,
13 glib,
14 fetchpatch,
15 ...
16}:
17
18beamPackages.mixRelease rec {
19 pname = "pleroma";
20 version = "2.9.1";
21
22 src = fetchFromGitLab {
23 domain = "git.pleroma.social";
24 owner = "pleroma";
25 repo = "pleroma";
26 rev = "v${version}";
27 sha256 = "sha256-mZcr+LlRQFDZVU5yAm0XkFdFHCDp4DZNLoVUlWxknMI=";
28 };
29
30 patches = [ ./Revert-Config-Restrict-permissions-of-OTP-config.patch ];
31
32 mixNixDeps = import ./mix.nix {
33 inherit beamPackages lib;
34 overrides = final: prev: {
35 # Upstream is pointing to
36 # https://github.com/feld/phoenix/commits/v1.7.14-websocket-headers/
37 # which is v1.7.14 with an extra patch applied on top.
38 phoenix = beamPackages.buildMix {
39 name = "phoenix";
40 version = "1.7.14-websocket-headers";
41 src = fetchFromGitHub {
42 owner = "phoenixframework";
43 repo = "phoenix";
44 tag = "v1.7.14";
45 hash = "sha256-hb8k0bUl28re1Bv2AIs17VHOP8zIyCfbpaVydu1Dh24=";
46 };
47 patches = [
48 (fetchpatch {
49 name = "0001-Support-passing-through-the-value-of-the-sec-websocket-protocol-header.patch";
50 url = "https://github.com/feld/phoenix/commit/fb6dc76c657422e49600896c64aab4253fceaef6.patch";
51 hash = "sha256-eMla+D3EcVTc1WwlRaKvLPV5eXwGfAgZOxiYlGSkBIQ=";
52 })
53 ];
54 beamDeps = with final; [
55 phoenix_pubsub
56 plug
57 plug_crypto
58 telemetry
59 phoenix_template
60 websock_adapter
61 phoenix_view
62 castore
63 plug_cowboy
64 jason
65 ];
66 };
67 # mix2nix does not support git dependencies yet,
68 # so we need to add them manually
69 captcha = beamPackages.buildMix {
70 name = "captcha";
71 version = "0.1.0";
72
73 src = fetchFromGitLab {
74 domain = "git.pleroma.social";
75 owner = "pleroma/elixir-libraries";
76 repo = "elixir-captcha";
77 rev = "90f6ce7672f70f56708792a98d98bd05176c9176";
78 sha256 = "sha256-s7EuAhmCsQA/4p2NJHJSWB/DZ5hA+7EelPsUOvKr2Po=";
79 };
80 beamDeps = [ ];
81 };
82 prometheus_ex = beamPackages.buildMix {
83 name = "prometheus_ex";
84 version = "3.0.5";
85
86 src = fetchFromGitHub {
87 owner = "lanodan";
88 repo = "prometheus.ex";
89 rev = "31f7fbe4b71b79ba27efc2a5085746c4011ceb8f";
90 hash = "sha256-2PZP+YnwnHt69HtIAQvjMBqBbfdbkRSoMzb1AL2Zsyc=";
91 };
92 beamDeps = with final; [ prometheus ];
93 };
94 remote_ip = beamPackages.buildMix {
95 name = "remote_ip";
96 version = "0.1.5";
97
98 src = fetchFromGitLab {
99 domain = "git.pleroma.social";
100 owner = "pleroma/elixir-libraries";
101 repo = "remote_ip";
102 rev = "b647d0deecaa3acb140854fe4bda5b7e1dc6d1c8";
103 hash = "sha256-pgON0uhTPVeeAC866Qz24Jvm1okoAECAHJrRzqaq+zA=";
104 };
105 beamDeps = with final; [
106 combine
107 plug
108 inet_cidr
109 ];
110 };
111 majic = prev.majic.override { buildInputs = [ file ]; };
112 # Some additional build inputs and build fixes
113 http_signatures = prev.http_signatures.override {
114 patchPhase = ''
115 substituteInPlace mix.exs --replace ":logger" ":logger, :public_key"
116 '';
117 };
118 fast_html = prev.fast_html.override {
119 nativeBuildInputs = [ cmake ];
120 dontUseCmakeConfigure = true;
121 };
122
123 syslog = prev.syslog.override { buildPlugins = with beamPackages; [ pc ]; };
124
125 vix = prev.vix.override {
126 nativeBuildInputs = [ pkg-config ];
127 buildInputs = [
128 vips
129 glib.dev
130 ];
131 VIX_COMPILATION_MODE = "PLATFORM_PROVIDED_LIBVIPS";
132 };
133
134 # This needs a different version (1.0.14 -> 1.0.18) to build properly with
135 # our Erlang/OTP version.
136 eimp = beamPackages.buildRebar3 rec {
137 name = "eimp";
138 version = "1.0.18";
139
140 src = beamPackages.fetchHex {
141 pkg = name;
142 inherit version;
143 sha256 = "0fnx2pm1n2m0zs2skivv43s42hrgpq9i143p9mngw9f3swjqpxvx";
144 };
145
146 patchPhase = ''
147 echo '{plugins, [pc]}.' >> rebar.config
148 '';
149 buildPlugins = with beamPackages; [ pc ];
150
151 beamDeps = with final; [ p1_utils ];
152 };
153 # Required by eimp
154 p1_utils = beamPackages.buildRebar3 rec {
155 name = "p1_utils";
156 version = "1.0.18";
157
158 src = fetchHex {
159 pkg = "${name}";
160 inherit version;
161 sha256 = "120znzz0yw1994nk6v28zql9plgapqpv51n9g6qm6md1f4x7gj0z";
162 };
163
164 beamDeps = [ ];
165 };
166
167 mime = prev.mime.override {
168 patchPhase =
169 let
170 cfgFile = writeText "config.exs" ''
171 use Mix.Config
172 config :mime, :types, %{
173 "application/activity+json" => ["activity+json"],
174 "application/jrd+json" => ["jrd+json"],
175 "application/ld+json" => ["activity+json"],
176 "application/xml" => ["xml"],
177 "application/xrd+xml" => ["xrd+xml"]
178 }
179 '';
180 in
181 ''
182 mkdir config
183 cp ${cfgFile} config/config.exs
184 '';
185 };
186 };
187 };
188
189 passthru = {
190 tests.pleroma = nixosTests.pleroma;
191 inherit mixNixDeps;
192 };
193
194 meta = with lib; {
195 description = "ActivityPub microblogging server";
196 homepage = "https://git.pleroma.social/pleroma/pleroma";
197 license = licenses.agpl3Only;
198 maintainers = with maintainers; [
199 picnoir
200 kloenk
201 yayayayaka
202 ];
203 platforms = platforms.unix;
204 };
205}