mastodon: 4.3.1 -> 4.3.2 (#361487)
[NixPkgs.git] / pkgs / servers / akkoma / default.nix
blob8336cb4a9af4b190dda3dea0c30c34c530d32f0a
1 { lib
2 , beamPackages
3 , fetchFromGitea
4 , fetchFromGitHub
5 , fetchFromGitLab
6 , cmake
7 , file
8 , nixosTests
9 , ...
11 beamPackages.mixRelease rec {
12   pname = "akkoma";
13   version = "3.13.2";
15   src = fetchFromGitea {
16     domain = "akkoma.dev";
17     owner = "AkkomaGang";
18     repo = "akkoma";
19     rev = "v${version}";
20     hash = "sha256-WZAkpJIPzAbqXawNiM3JqE9tJzxrNs/2dGAWVMwLpN4=";
21   };
23   postPatch = ''
24     # Remove dependency on OS_Mon
25     sed -E -i 's/(^|\s):os_mon,//' \
26       mix.exs
27   '';
29   postBuild = ''
30     # Digest and compress static files
31     rm -f priv/static/READ_THIS_BEFORE_TOUCHING_FILES_HERE
32     mix phx.digest --no-deps-check
33   '';
35   mixNixDeps = import ./mix.nix {
36     inherit beamPackages lib;
37     overrides = final: prev:
38       let
39         mimeTypePatchPhase = ''
40           mkdir -p config
41           cat >> config/config.exs <<EOF
42           Mix.Config.config :mime, :types, %{
43             "application/xml" => ["xml"],
44             "application/xrd+xml" => ["xrd+xml"],
45             "application/jrd+json" => ["jrd+json"],
46             "application/activity+json" => ["activity+json"],
47             "application/ld+json" => ["activity+json"],
48             "image/apng" => ["apng"]
49           }
50           Mix.Config.config :mime, :extensions, %{
51             "activity+json" => "text/plain",
52             "jrd+json" => "text/plain",
53             "xrd+xml" => "text/plain"
54           }
55           EOF
56         '';
57         # Akkoma adds some things to the `mime` package's configuration, which requires it to be recompiled.
58         # However, we can't just recompile things like we would on other systems.
59         # Therefore, we need to add it to mime's compile-time config too, and also in every package that depends on mime, directly or indirectly.
60         # We take the lazy way out and just add it to every dependency - it won't make a difference in packages that don't depend on `mime`.
61         addMimeTypes = _: p: p.override {
62           patchPhase = mimeTypePatchPhase;
63         };
64       in
65       (lib.attrsets.mapAttrs addMimeTypes prev) // {
66         # mix2nix does not support git dependencies yet,
67         # so we need to add them manually
68         captcha = beamPackages.buildMix rec {
69           name = "captcha";
70           version = "0.1.0";
72           src = fetchFromGitLab {
73             domain = "git.pleroma.social";
74             group = "pleroma";
75             owner = "elixir-libraries";
76             repo = "elixir-captcha";
77             rev = "90f6ce7672f70f56708792a98d98bd05176c9176";
78             hash = "sha256-s7EuAhmCsQA/4p2NJHJSWB/DZ5hA+7EelPsUOvKr2Po=";
79           };
81           # the binary is not getting installed by default
82           postInstall = "mv priv/* $out/lib/erlang/lib/${name}-${version}/priv/";
83         };
84         concurrent_limiter = beamPackages.buildMix rec {
85           name = "concurrent_limiter";
86           version = "0.1.1";
88           src = fetchFromGitea {
89             domain = "akkoma.dev";
90             owner = "AkkomaGang";
91             repo = "concurrent-limiter";
92             rev = "a9e0b3d64574bdba761f429bb4fba0cf687b3338";
93             hash = "sha256-A7ucZnXks4K+JDVY5vV2cT5KfEOUOo/OHO4rga5mGys=";
94           };
95         };
96         elasticsearch = beamPackages.buildMix rec {
97           name = "elasticsearch";
98           version = "1.0.1";
100           src = fetchFromGitea {
101             domain = "akkoma.dev";
102             owner = "AkkomaGang";
103             repo = "elasticsearch-elixir";
104             rev = "6cd946f75f6ab9042521a009d1d32d29a90113ca";
105             hash = "sha256-CtmQHVl+VTpemne+nxbkYGcErrgCo+t3ZBPbkFSpyF0=";
106           };
107         };
108         linkify = beamPackages.buildMix rec {
109           name = "linkify";
110           version = "0.5.2";
112           src = fetchFromGitea {
113             domain = "akkoma.dev";
114             owner = "AkkomaGang";
115             repo = "linkify";
116             rev = "2567e2c1073fa371fd26fd66dfa5bc77b6919c16";
117             hash = "sha256-e3wzlbRuyw/UB5Tb7IozX/WR1T+sIBf9C/o5Thki9vg=";
118           };
119         };
120         mfm_parser = beamPackages.buildMix rec {
121           name = "mfm_parser";
122           version = "0.1.1";
124           src = fetchFromGitea {
125             domain = "akkoma.dev";
126             owner = "AkkomaGang";
127             repo = "mfm-parser";
128             rev = "b21ab7754024af096f2d14247574f55f0063295b";
129             hash = "sha256-couG5jrAo0Fbk/WABd4n3vhXpDUp+9drxExKc5NM9CI=";
130           };
132           beamDeps = with final; [ phoenix_view temple ];
133           patchPhase = mimeTypePatchPhase;
134         };
135         search_parser = beamPackages.buildMix rec {
136           name = "search_parser";
137           version = "0.1.0";
139           src = fetchFromGitHub {
140             owner = "FloatingGhost";
141             repo = "pleroma-contrib-search-parser";
142             rev = "08971a81e68686f9ac465cfb6661d51c5e4e1e7f";
143             hash = "sha256-sbo9Kcp2oT05o2GAF+IgziLPYmCkWgBfFMBCytmqg3Y=";
144           };
146           beamDeps = with final; [ nimble_parsec ];
147         };
148         temple = beamPackages.buildMix rec {
149           name = "temple";
150           version = "0.9.0-rc.0";
152           src = fetchFromGitea {
153             domain = "akkoma.dev";
154             owner = "AkkomaGang";
155             repo = "temple";
156             rev = "066a699ade472d8fa42a9d730b29a61af9bc8b59";
157             hash = "sha256-qA0z8WTMjO2OixcZBARn/LbuV3s3LGtwZ9nSjj/tWBc=";
158           };
160           mixEnv = "dev";
161           beamDeps = with final; [ earmark_parser ex_doc makeup makeup_elixir makeup_erlang nimble_parsec ];
162           patchPhase = mimeTypePatchPhase;
163         };
165         # Some additional build inputs and build fixes
166         fast_html = prev.fast_html.override {
167           nativeBuildInputs = [ cmake ];
168           dontUseCmakeConfigure = true;
169         };
170         http_signatures = beamPackages.buildMix rec {
171           name = "http_signatures";
172           version = "0.1.2";
174           src = fetchFromGitea {
175             domain = "akkoma.dev";
176             owner = "AkkomaGang";
177             repo = "http_signatures";
178             rev = "6640ce7d24c783ac2ef56e27d00d12e8dc85f396";
179             hash = "sha256-Q/IoVbM/TBgGCmx8AxiBHF2hARb0FbPml8N1HjN3CsE=";
180           };
182           beamDeps = with final; [ credo ex_doc dialyxir temple ];
183           patchPhase = ''
184             substituteInPlace mix.exs --replace ":logger" ":logger, :public_key"
185             ${mimeTypePatchPhase}
186           '';
187         };
188         majic = beamPackages.buildMix {
189           name = "majic";
190           version = "0.1.2";
192           src = fetchFromGitea {
193             domain = "akkoma.dev";
194             owner = "AkkomaGang";
195             repo = "majic";
196             rev = "80540b36939ec83f48e76c61e5000e0fd67706f0";
197             hash = "sha256-OMM9aDRvbqCOBIE+iPySU8ONRn1BqHDql22rRSmdW08=";
198           };
200           buildInputs = [ file ];
201           beamDeps = with final; [ nimble_pool mime plug credo dialyxir ex_doc elixir_make ];
202           patchPhase = mimeTypePatchPhase;
203         };
205         syslog = prev.syslog.override {
206           buildPlugins = with beamPackages; [ pc ];
207         };
208       };
209   };
211   passthru = {
212     tests = with nixosTests; { inherit akkoma akkoma-confined; };
213     inherit mixNixDeps;
215     # Used to make sure the service uses the same version of elixir as
216     # the package
217     elixirPackage = beamPackages.elixir;
218   };
220   meta = with lib; {
221     description = "ActivityPub microblogging server";
222     homepage = "https://akkoma.social";
223     license = licenses.agpl3Only;
224     maintainers = with maintainers; [ mvs ];
225     platforms = platforms.unix;
226   };