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