git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #103138 from NinjaTrappeur/nin-pleroma
commitab224b550cc1a303b87dd07d29a12fcd10da5489 authorNinjatrappeur <NinjaTrappeur@users.noreply.github.com> dateWed 27 Jan 2021, 13:28 (6 years ago) parent693c7cd60b730f
7 files changed+611
nixos/modules/module-list.nix+1 nixos/modules/services/networking/pleroma.nix+140 nixos/modules/services/networking/pleroma.xml+132 nixos/tests/all-tests.nix+1 nixos/tests/pleroma.nix+265 pkgs/servers/pleroma-otp/default.nix+70 pkgs/top-level/all-packages.nix+2
nixos/modules/module-list.nix+1
@@ -727,6 +727,7 @@
727727 ./services/networking/owamp.nix
728728 ./services/networking/pdnsd.nix
729729 ./services/networking/pixiecore.nix
730+ ./services/networking/pleroma.nix
730731 ./services/networking/polipo.nix
731732 ./services/networking/powerdns.nix
732733 ./services/networking/pdns-recursor.nix
nixos/modules/services/networking/pleroma.nixnew file+140
@@ -0,0 +1,140 @@
1+{ config, options, lib, pkgs, stdenv, ... }:
2+let
3+ cfg = config.services.pleroma;
4+in {
5+ options = {
6+ services.pleroma = with lib; {
7+ enable = mkEnableOption "pleroma";
8+
9+ package = mkOption {
10+ type = types.package;
11+ default = pkgs.pleroma-otp;
12+ description = "Pleroma package to use.";
13+ };
14+
15+ user = mkOption {
16+ type = types.str;
17+ default = "pleroma";
18+ description = "User account under which pleroma runs.";
19+ };
20+
21+ group = mkOption {
22+ type = types.str;
23+ default = "pleroma";
24+ description = "Group account under which pleroma runs.";
25+ };
26+
27+ stateDir = mkOption {
28+ type = types.str;
29+ default = "/var/lib/pleroma";
30+ readOnly = true;
31+ description = "Directory where the pleroma service will save the uploads and static files.";
32+ };
33+
34+ configs = mkOption {
35+ type = with types; listOf str;
36+ description = ''
37+ Pleroma public configuration.
38+
39+ This list gets appended from left to
40+ right into /etc/pleroma/config.exs. Elixir evaluates its
41+ configuration imperatively, meaning you can override a
42+ setting by appending a new str to this NixOS option list.
43+
44+ <emphasis>DO NOT STORE ANY PLEROMA SECRET
45+ HERE</emphasis>, use
46+ <link linkend="opt-services.pleroma.secretConfigFile">services.pleroma.secretConfigFile</link>
47+ instead.
48+
49+ This setting is going to be stored in a file part of
50+ the Nix store. The Nix store being world-readable, it's not
51+ the right place to store any secret
52+
53+ Have a look to Pleroma section in the NixOS manual for more
54+ informations.
55+ '';
56+ };
57+
58+ secretConfigFile = mkOption {
59+ type = types.str;
60+ default = "/var/lib/pleroma/secrets.exs";
61+ description = ''
62+ Path to the file containing your secret pleroma configuration.
63+
64+ <emphasis>DO NOT POINT THIS OPTION TO THE NIX
65+ STORE</emphasis>, the store being world-readable, it'll
66+ compromise all your secrets.
67+ '';
68+ };
69+ };
70+ };
71+
72+ config = lib.mkIf cfg.enable {
73+ users = {
74+ users."${cfg.user}" = {
75+ description = "Pleroma user";
76+ home = cfg.stateDir;
77+ extraGroups = [ cfg.group ];
78+ };
79+ groups."${cfg.group}" = {};
80+ };
81+
82+ environment.systemPackages = [ cfg.package ];
83+
84+ environment.etc."/pleroma/config.exs".text = ''
85+ ${lib.concatMapStrings (x: "${x}") cfg.configs}
86+
87+ # The lau/tzdata library is trying to download the latest
88+ # timezone database in the OTP priv directory by default.
89+ # This directory being in the store, it's read-only.
90+ # Setting that up to a more appropriate location.
91+ config :tzdata, :data_dir, "/var/lib/pleroma/elixir_tzdata_data"
92+
93+ import_config "${cfg.secretConfigFile}"
94+ '';
95+
96+ systemd.services.pleroma = {
97+ description = "Pleroma social network";
98+ after = [ "network-online.target" "postgresql.service" ];
99+ wantedBy = [ "multi-user.target" ];
100+ restartTriggers = [ config.environment.etc."/pleroma/config.exs".source ];
101+ serviceConfig = {
102+ User = cfg.user;
103+ Group = cfg.group;
104+ Type = "exec";
105+ WorkingDirectory = "~";
106+ StateDirectory = "pleroma pleroma/static pleroma/uploads";
107+ StateDirectoryMode = "700";
108+
109+ # Checking the conf file is there then running the database
110+ # migration before each service start, just in case there are
111+ # some pending ones.
112+ #
113+ # It's sub-optimal as we'll always run this, even if pleroma
114+ # has not been updated. But the no-op process is pretty fast.
115+ # Better be safe than sorry migration-wise.
116+ ExecStartPre =
117+ let preScript = pkgs.writers.writeBashBin "pleromaStartPre"
118+ "${cfg.package}/bin/pleroma_ctl migrate";
119+ in "${preScript}/bin/pleromaStartPre";
120+
121+ ExecStart = "${cfg.package}/bin/pleroma start";
122+ ExecStop = "${cfg.package}/bin/pleroma stop";
123+ ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
124+
125+ # Systemd sandboxing directives.
126+ # Taken from the upstream contrib systemd service at
127+ # pleroma/installation/pleroma.service
128+ PrivateTmp = true;
129+ ProtectHome = true;
130+ ProtectSystem = "full";
131+ PrivateDevices = false;
132+ NoNewPrivileges = true;
133+ CapabilityBoundingSet = "~CAP_SYS_ADMIN";
134+ };
135+ };
136+
137+ };
138+ meta.maintainers = with lib.maintainers; [ ninjatrappeur ];
139+ meta.doc = ./pleroma.xml;
140+}
nixos/modules/services/networking/pleroma.xmlnew file+132
@@ -0,0 +1,132 @@
1+<chapter xmlns="http://docbook.org/ns/docbook"
2+ xmlns:xlink="http://www.w3.org/1999/xlink"
3+ xmlns:xi="http://www.w3.org/2001/XInclude"
4+ version="5.0"
5+ xml:id="module-services-pleroma">
6+ <title>Pleroma</title>
7+ <para><link xlink:href="https://pleroma.social/">Pleroma</link> is a lightweight activity pub server.</para>
8+ <section xml:id="module-services-pleroma-getting-started">
9+ <title>Quick Start</title>
10+ <para>To get quickly started, you can use this sample NixOS configuration and adapt it to your use case.</para>
11+ <para><programlisting>
12+ {
13+ security.acme = {
14+ email = "root@tld";
15+ acceptTerms = true;
16+ certs = {
17+ "social.tld.com" = {
18+ webroot = "/var/www/social.tld.com";
19+ email = "root@tld";
20+ group = "nginx";
21+ };
22+ };
23+ };
24+ services = {
25+ pleroma = {
26+ enable = true;
27+ secretConfigFile = "/var/lib/pleroma/secrets.exs";
28+ configs = [
29+ ''
30+ import Config
31+
32+ config :pleroma, Pleroma.Web.Endpoint,
33+ url: [host: "social.tld.com", scheme: "https", port: 443],
34+ http: [ip: {127, 0, 0, 1}, port: 4000]
35+
36+ config :pleroma, :instance,
37+ name: "NixOS test pleroma server",
38+ email: "pleroma@social.tld.com",
39+ notify_email: "pleroma@social.tld.com",
40+ limit: 5000,
41+ registrations_open: true
42+
43+ config :pleroma, :media_proxy,
44+ enabled: false,
45+ redirect_on_failure: true
46+ #base_url: "https://cache.pleroma.social"
47+
48+ config :pleroma, Pleroma.Repo,
49+ adapter: Ecto.Adapters.Postgres,
50+ username: "pleroma",
51+ password: "${test-db-passwd}",
52+ database: "pleroma",
53+ hostname: "localhost",
54+ pool_size: 10,
55+ prepare: :named,
56+ parameters: [
57+ plan_cache_mode: "force_custom_plan"
58+ ]
59+
60+ config :pleroma, :database, rum_enabled: false
61+ config :pleroma, :instance, static_dir: "/var/lib/pleroma/static"
62+ config :pleroma, Pleroma.Uploaders.Local, uploads: "/var/lib/pleroma/uploads"
63+ config :pleroma, configurable_from_database: false
64+ ''
65+ ];
66+ };
67+ postgresql = {
68+ enable = true;
69+ package = pkgs.postgresql_12;
70+ };
71+ nginx = {
72+ enable = true;
73+ addSSL = true;
74+ sslCertificate = "/var/lib/acme/social.tld.com/fullchain.pem";
75+ sslCertificateKey = "/var/lib/acme/social.tld.com/key.pem";
76+ root = "/var/www/social.tld.com";
77+ # ACME endpoint
78+ locations."/.well-known/acme-challenge" = {
79+ root = "/var/www/social.tld.com/";
80+ };
81+ virtualHosts."social.tld.com" = {
82+ addSSL = true;
83+ locations."/" = {
84+ proxyPass = "http://127.0.0.1:4000";
85+ extraConfig = ''
86+ add_header 'Access-Control-Allow-Origin' '*' always;
87+ add_header 'Access-Control-Allow-Methods' 'POST, PUT, DELETE, GET, PATCH, OPTIONS' always;
88+ add_header 'Access-Control-Allow-Headers' 'Authorization, Content-Type, Idempotency-Key' always;
89+ add_header 'Access-Control-Expose-Headers' 'Link, X-RateLimit-Reset, X-RateLimit-Limit, X-RateLimit-Remaining, X-Request-Id' always;
90+ if ($request_method = OPTIONS) {
91+ return 204;
92+ }
93+ add_header X-XSS-Protection "1; mode=block";
94+ add_header X-Permitted-Cross-Domain-Policies none;
95+ add_header X-Frame-Options DENY;
96+ add_header X-Content-Type-Options nosniff;
97+ add_header Referrer-Policy same-origin;
98+ add_header X-Download-Options noopen;
99+ proxy_http_version 1.1;
100+ proxy_set_header Upgrade $http_upgrade;
101+ proxy_set_header Connection "upgrade";
102+ proxy_set_header Host $host;
103+ client_max_body_size 16m;
104+ '';
105+ };
106+ };
107+ };
108+ };
109+ };
110+ </programlisting></para>
111+ <para>Note that you'll need to seed your database and upload your pleroma secrets to the path pointed by <literal>config.pleroma.secretConfigFile</literal>. You can find more informations about how to do that in the <link linkend="module-services-pleroma-generate-config">next</link> section.</para>
112+ </section>
113+ <section xml:id="module-services-pleroma-generate-config">
114+ <title>Generating the Pleroma Config and Seed the Database</title>
115+
116+ <para>Before using this service, you'll need to generate your
117+server configuration and its associated database seed. The
118+<literal>pleroma_ctl</literal> CLI utility can help you with that. You
119+can start with <literal>pleroma_ctl instance gen --output config.exs
120+--output-psql setup.psql</literal>, this will prompt you some
121+questions and will generate both your config file and database initial
122+migration. </para>
123+<para>For more details about this configuration format, please have a look at the <link xlink:href="https://docs-develop.pleroma.social/backend/configuration/cheatsheet/">upstream documentation</link>.</para>
124+<para>To seed your database, you can use the <literal>setup.psql</literal> file you just generated by running
125+<programlisting>
126+ sudo -u postgres psql -f setup.psql
127+</programlisting></para>
128+ <para>In regard of the pleroma service configuration you also just generated, you'll need to split it in two parts. The "public" part, which do not contain any secrets and thus can be safely stored in the Nix store and its "private" counterpart containing some secrets (database password, endpoint secret key, salts, etc.).</para>
129+
130+ <para>The public part will live in your NixOS machine configuration in the <link linkend="opt-services.pleroma.configs">services.pleroma.configs</link> option. However, it's up to you to upload the secret pleroma configuration to the path pointed by <link linkend="opt-services.pleroma.secretConfigFile">services.pleroma.secretConfigFile</link>. You can do that manually or rely on a third party tool such as <link xlink:href="https://github.com/DBCDK/morph">Morph</link> or <link xlink:href="https://github.com/NixOS/nixops">NixOps</link>.</para>
131+ </section>
132+</chapter>
nixos/tests/all-tests.nix+1
@@ -302,6 +302,7 @@ in
302302 php = handleTest ./php {};
303303 pinnwand = handleTest ./pinnwand.nix {};
304304 plasma5 = handleTest ./plasma5.nix {};
305+ pleroma = handleTestOn [ "x86_64-linux" "aarch64-linux" ] ./pleroma.nix {};
305306 plotinus = handleTest ./plotinus.nix {};
306307 podman = handleTestOn ["x86_64-linux"] ./podman.nix {};
307308 postfix = handleTest ./postfix.nix {};
nixos/tests/pleroma.nixnew file+265
@@ -0,0 +1,265 @@
1+/*
2+ Pleroma E2E VM test.
3+
4+ Abstract:
5+ =========
6+ Using pleroma, postgresql, a local CA cert, a nginx reverse proxy
7+ and a toot-based client, we're going to:
8+
9+ 1. Provision a pleroma service from scratch (pleroma config + postgres db).
10+ 2. Create a "jamy" admin user.
11+ 3. Send a toot from this user.
12+ 4. Send a upload from this user.
13+ 5. Check the toot is part of the server public timeline
14+
15+ Notes:
16+ - We need a fully functional TLS setup without having any access to
17+ the internet. We do that by issuing a self-signed cert, add this
18+ self-cert to the hosts pki trust store and finally spoof the
19+ hostnames using /etc/hosts.
20+ - For this NixOS test, we *had* to store some DB-related and
21+ pleroma-related secrets to the store. Keep in mind the store is
22+ world-readable, it's the worst place possible to store *any*
23+ secret. **DO NOT DO THIS IN A REAL WORLD DEPLOYMENT**.
24+*/
25+
26+import ./make-test-python.nix ({ pkgs, ... }:
27+ let
28+ send-toot = pkgs.writeScriptBin "send-toot" ''
29+ set -eux
30+ # toot is using the requests library internally. This library
31+ # sadly embed its own certificate store instead of relying on the
32+ # system one. Overriding this pretty bad default behaviour.
33+ export REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
34+
35+ export TOOT_LOGIN_CLI_PASSWORD="jamy-password"
36+ toot login_cli -i "pleroma.nixos.test" -e "jamy@nixos.test"
37+ echo "Login OK"
38+
39+ # Send a toot then verify it's part of the public timeline
40+ echo "y" | toot post "hello world Jamy here"
41+ echo "Send toot OK"
42+ echo "y" | toot timeline | grep -c "hello world Jamy here"
43+ echo "Get toot from timeline OK"
44+
45+ # Test file upload
46+ echo "y" | toot upload ${db-seed} | grep -c "https://pleroma.nixos.test/media"
47+ echo "File upload OK"
48+
49+ echo "====================================================="
50+ echo "= SUCCESS ="
51+ echo "= ="
52+ echo "= We were able to sent a toot + a upload and ="
53+ echo "= retrieve both of them in the public timeline. ="
54+ echo "====================================================="
55+ '';
56+
57+ provision-db = pkgs.writeScriptBin "provision-db" ''
58+ set -eux
59+ sudo -u postgres psql -f ${db-seed}
60+ '';
61+
62+ test-db-passwd = "SccZOvTGM//BMrpoQj68JJkjDkMGb4pHv2cECWiI+XhVe3uGJTLI0vFV/gDlZ5jJ";
63+
64+ /* For this NixOS test, we *had* to store this secret to the store.
65+ Keep in mind the store is world-readable, it's the worst place
66+ possible to store *any* secret. **DO NOT DO THIS IN A REAL WORLD
67+ DEPLOYMENT**.*/
68+ db-seed = pkgs.writeText "provision.psql" ''
69+ CREATE USER pleroma WITH ENCRYPTED PASSWORD '${test-db-passwd}';
70+ CREATE DATABASE pleroma OWNER pleroma;
71+ \c pleroma;
72+ --Extensions made by ecto.migrate that need superuser access
73+ CREATE EXTENSION IF NOT EXISTS citext;
74+ CREATE EXTENSION IF NOT EXISTS pg_trgm;
75+ CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
76+ '';
77+
78+ pleroma-conf = ''
79+ import Config
80+
81+ config :pleroma, Pleroma.Web.Endpoint,
82+ url: [host: "pleroma.nixos.test", scheme: "https", port: 443],
83+ http: [ip: {127, 0, 0, 1}, port: 4000]
84+
85+ config :pleroma, :instance,
86+ name: "NixOS test pleroma server",
87+ email: "pleroma@nixos.test",
88+ notify_email: "pleroma@nixos.test",
89+ limit: 5000,
90+ registrations_open: true
91+
92+ config :pleroma, :media_proxy,
93+ enabled: false,
94+ redirect_on_failure: true
95+ #base_url: "https://cache.pleroma.social"
96+
97+ config :pleroma, Pleroma.Repo,
98+ adapter: Ecto.Adapters.Postgres,
99+ username: "pleroma",
100+ password: "${test-db-passwd}",
101+ database: "pleroma",
102+ hostname: "localhost",
103+ pool_size: 10,
104+ prepare: :named,
105+ parameters: [
106+ plan_cache_mode: "force_custom_plan"
107+ ]
108+
109+ config :pleroma, :database, rum_enabled: false
110+ config :pleroma, :instance, static_dir: "/var/lib/pleroma/static"
111+ config :pleroma, Pleroma.Uploaders.Local, uploads: "/var/lib/pleroma/uploads"
112+ config :pleroma, configurable_from_database: false
113+ '';
114+
115+ /* For this NixOS test, we *had* to store this secret to the store.
116+ Keep in mind the store is world-readable, it's the worst place
117+ possible to store *any* secret. **DO NOT DO THIS IN A REAL WORLD
118+ DEPLOYMENT**.
119+ In a real-word deployment, you'd handle this either by:
120+ - manually upload your pleroma secrets to /var/lib/pleroma/secrets.exs
121+ - use a deployment tool such as morph or NixOps to deploy your secrets.
122+ */
123+ pleroma-conf-secret = pkgs.writeText "secrets.exs" ''
124+ import Config
125+
126+ config :joken, default_signer: "PS69/wMW7X6FIQPABt9lwvlZvgrJIncfiAMrK9J5mjVus/7/NJJi1DsDA1OghBE5"
127+
128+ config :pleroma, Pleroma.Web.Endpoint,
129+ secret_key_base: "NvfmU7lYaQrmmxt4NACm0AaAfN9t6WxsrX0NCB4awkGHvr1S7jyshlEmrjaPFhhq",
130+ signing_salt: "3L41+BuJ"
131+
132+ config :web_push_encryption, :vapid_details,
133+ subject: "mailto:pleroma@nixos.test",
134+ public_key: "BKjfNX9-UqAcncaNqERQtF7n9pKrB0-MO-juv6U5E5XQr_Tg5D-f8AlRjduAguDpyAngeDzG8MdrTejMSL4VF30",
135+ private_key: "k7o9onKMQrgMjMb6l4fsxSaXO0BTNAer5MVSje3q60k"
136+ '';
137+
138+ /* For this NixOS test, we *had* to store this secret to the store.
139+ Keep in mind the store is world-readable, it's the worst place
140+ possible to store *any* secret. **DO NOT DO THIS IN A REAL WORLD
141+ DEPLOYMENT**.
142+ In a real-word deployment, you'd handle this either by:
143+ - manually upload your pleroma secrets to /var/lib/pleroma/secrets.exs
144+ - use a deployment tool such as morph or NixOps to deploy your secrets.
145+ */
146+ provision-secrets = pkgs.writeScriptBin "provision-secrets" ''
147+ set -eux
148+ cp "${pleroma-conf-secret}" "/var/lib/pleroma/secrets.exs"
149+ chown pleroma:pleroma /var/lib/pleroma/secrets.exs
150+ '';
151+
152+ /* For this NixOS test, we *had* to store this secret to the store.
153+ Keep in mind the store is world-readable, it's the worst place
154+ possible to store *any* secret. **DO NOT DO THIS IN A REAL WORLD
155+ DEPLOYMENT**.
156+ */
157+ provision-user = pkgs.writeScriptBin "provision-user" ''
158+ set -eux
159+
160+ # Waiting for pleroma to be up.
161+ timeout 5m bash -c 'while [[ "$(curl -s -o /dev/null -w '%{http_code}' https://pleroma.nixos.test/api/v1/instance)" != "200" ]]; do sleep 2; done'
162+ pleroma_ctl user new jamy jamy@nixos.test --password 'jamy-password' --moderator --admin -y
163+ '';
164+
165+ tls-cert = pkgs.runCommandNoCC "selfSignedCerts" { buildInputs = [ pkgs.openssl ]; } ''
166+ openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -nodes -subj '/CN=pleroma.nixos.test'
167+ mkdir -p $out
168+ cp key.pem cert.pem $out
169+ '';
170+
171+ /* Toot is preventing users from feeding login_cli a password non
172+ interactively. While it makes sense most of the times, it's
173+ preventing us to login in this non-interactive test. This patch
174+ introduce a TOOT_LOGIN_CLI_PASSWORD env variable allowing us to
175+ provide a password to toot login_cli
176+
177+ If https://github.com/ihabunek/toot/pull/180 gets merged at some
178+ point, feel free to remove this patch. */
179+ custom-toot = pkgs.toot.overrideAttrs(old:{
180+ patches = [ (pkgs.fetchpatch {
181+ url = "https://github.com/NinjaTrappeur/toot/commit/b4a4c30f41c0cb7e336714c2c4af9bc9bfa0c9f2.patch";
182+ sha256 = "sha256-0xxNwjR/fStLjjUUhwzCCfrghRVts+fc+fvVJqVcaFg=";
183+ }) ];
184+ });
185+
186+ hosts = nodes: ''
187+ ${nodes.pleroma.config.networking.primaryIPAddress} pleroma.nixos.test
188+ ${nodes.client.config.networking.primaryIPAddress} client.nixos.test
189+ '';
190+ in {
191+ name = "pleroma";
192+ nodes = {
193+ client = { nodes, pkgs, config, ... }: {
194+ security.pki.certificateFiles = [ "${tls-cert}/cert.pem" ];
195+ networking.extraHosts = hosts nodes;
196+ environment.systemPackages = with pkgs; [
197+ custom-toot
198+ send-toot
199+ ];
200+ };
201+ pleroma = { nodes, pkgs, config, ... }: {
202+ security.pki.certificateFiles = [ "${tls-cert}/cert.pem" ];
203+ networking.extraHosts = hosts nodes;
204+ networking.firewall.enable = false;
205+ environment.systemPackages = with pkgs; [
206+ provision-db
207+ provision-secrets
208+ provision-user
209+ ];
210+ services = {
211+ pleroma = {
212+ enable = true;
213+ configs = [
214+ pleroma-conf
215+ ];
216+ };
217+ postgresql = {
218+ enable = true;
219+ package = pkgs.postgresql_12;
220+ };
221+ nginx = {
222+ enable = true;
223+ virtualHosts."pleroma.nixos.test" = {
224+ addSSL = true;
225+ sslCertificate = "${tls-cert}/cert.pem";
226+ sslCertificateKey = "${tls-cert}/key.pem";
227+ locations."/" = {
228+ proxyPass = "http://127.0.0.1:4000";
229+ extraConfig = ''
230+ add_header 'Access-Control-Allow-Origin' '*' always;
231+ add_header 'Access-Control-Allow-Methods' 'POST, PUT, DELETE, GET, PATCH, OPTIONS' always;
232+ add_header 'Access-Control-Allow-Headers' 'Authorization, Content-Type, Idempotency-Key' always;
233+ add_header 'Access-Control-Expose-Headers' 'Link, X-RateLimit-Reset, X-RateLimit-Limit, X-RateLimit-Remaining, X-Request-Id' always;
234+ if ($request_method = OPTIONS) {
235+ return 204;
236+ }
237+ add_header X-XSS-Protection "1; mode=block";
238+ add_header X-Permitted-Cross-Domain-Policies none;
239+ add_header X-Frame-Options DENY;
240+ add_header X-Content-Type-Options nosniff;
241+ add_header Referrer-Policy same-origin;
242+ add_header X-Download-Options noopen;
243+ proxy_http_version 1.1;
244+ proxy_set_header Upgrade $http_upgrade;
245+ proxy_set_header Connection "upgrade";
246+ proxy_set_header Host $host;
247+ client_max_body_size 16m;
248+ '';
249+ };
250+ };
251+ };
252+ };
253+ };
254+ };
255+
256+ testScript = { nodes, ... }: ''
257+ pleroma.wait_for_unit("postgresql.service")
258+ pleroma.succeed("provision-db")
259+ pleroma.succeed("provision-secrets")
260+ pleroma.systemctl("restart pleroma.service")
261+ pleroma.wait_for_unit("pleroma.service")
262+ pleroma.succeed("provision-user")
263+ client.succeed("send-toot")
264+ '';
265+})
pkgs/servers/pleroma-otp/default.nixnew file+70
@@ -0,0 +1,70 @@
1+{ stdenv
2+, autoPatchelfHook
3+, fetchurl
4+, file
5+, makeWrapper
6+, ncurses
7+, nixosTests
8+, openssl
9+, unzip
10+, zlib
11+}:
12+stdenv.mkDerivation {
13+ pname = "pleroma-otp";
14+ version = "2.2.2";
15+
16+ # To find the latest binary release stable link, have a look at
17+ # the CI pipeline for the latest commit of the stable branch
18+ # https://git.pleroma.social/pleroma/pleroma/-/tree/stable
19+ src = {
20+ aarch64-linux = fetchurl {
21+ url = "https://git.pleroma.social/pleroma/pleroma/-/jobs/175288/artifacts/download";
22+ sha256 = "107kp5zqwq1lixk1cwkx4v7zpm0h248xzlm152aj36ghb43j2snw";
23+ };
24+ x86_64-linux = fetchurl {
25+ url = "https://git.pleroma.social/pleroma/pleroma/-/jobs/175284/artifacts/download";
26+ sha256 = "1c6l04gga9iigm249ywwcrjg6wzy8iiid652mws3j9dnl71w2sim";
27+ };
28+ }."${stdenv.hostPlatform.system}";
29+
30+ nativeBuildInputs = [ unzip ];
31+
32+ buildInputs = [
33+ autoPatchelfHook
34+ file
35+ makeWrapper
36+ ncurses
37+ openssl
38+ zlib
39+ ];
40+
41+ # mkDerivation fails to detect the zip nature of $src due to the
42+ # missing .zip extension.
43+ # Let's unpack the archive explicitely.
44+ unpackCmd = "unzip $curSrc";
45+
46+ installPhase = ''
47+ mkdir $out
48+ cp -r * $out'';
49+
50+ # Pleroma is using the project's root path (here the store path)
51+ # as its TMPDIR.
52+ # Patching it to move the tmp dir to the actual tmpdir
53+ postFixup = ''
54+ wrapProgram $out/bin/pleroma \
55+ --set-default RELEASE_TMP "/tmp"
56+ wrapProgram $out/bin/pleroma_ctl \
57+ --set-default RELEASE_TMP "/tmp"'';
58+
59+ passthru.tests = {
60+ pleroma = nixosTests.pleroma;
61+ };
62+
63+ meta = {
64+ description = "ActivityPub microblogging server";
65+ homepage = https://git.pleroma.social/pleroma/pleroma;
66+ license = stdenv.lib.licenses.agpl3;
67+ maintainers = with stdenv.lib.maintainers; [ ninjatrappeur ];
68+ platforms = [ "x86_64-linux" "aarch64-linux" ];
69+ };
70+}
pkgs/top-level/all-packages.nix+2
@@ -7055,6 +7055,8 @@ in
70557055
70567056 tautulli = python3Packages.callPackage ../servers/tautulli { };
70577057
7058+ pleroma-otp = callPackage ../servers/pleroma-otp { };
7059+
70587060 ploticus = callPackage ../tools/graphics/ploticus {
70597061 libpng = libpng12;
70607062 };