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