git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #160750 from Izorkin/update-prosody
commit018a959be75bc57b44b717a296c562acf3a26eb6 authorFranz Pletz <fpletz@fnordicwalking.de> dateTue 15 Mar 2022, 19:07 (5 years ago) parentd1b993a7629826
4 files changed+131−9
nixos/tests/all-tests.nix+1 nixos/tests/xmpp/prosody-mysql.nix+124 nixos/tests/xmpp/prosody.nix+1 pkgs/servers/xmpp/prosody/default.nix+5−9
nixos/tests/all-tests.nix+1
@@ -433,6 +433,7 @@ in
433433 prometheus = handleTest ./prometheus.nix {};
434434 prometheus-exporters = handleTest ./prometheus-exporters.nix {};
435435 prosody = handleTest ./xmpp/prosody.nix {};
436+ prosody-mysql = handleTest ./xmpp/prosody-mysql.nix {};
436437 proxy = handleTest ./proxy.nix {};
437438 prowlarr = handleTest ./prowlarr.nix {};
438439 pt2-clone = handleTest ./pt2-clone.nix {};
nixos/tests/xmpp/prosody-mysql.nixnew file+124
@@ -0,0 +1,124 @@
1+let
2+ cert = pkgs: pkgs.runCommand "selfSignedCerts" { buildInputs = [ pkgs.openssl ]; } ''
3+ openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -nodes -subj '/CN=example.com/CN=uploads.example.com/CN=conference.example.com' -days 36500
4+ mkdir -p $out
5+ cp key.pem cert.pem $out
6+ '';
7+ createUsers = pkgs: pkgs.writeScriptBin "create-prosody-users" ''
8+ #!${pkgs.bash}/bin/bash
9+ set -e
10+
11+ # Creates and set password for the 2 xmpp test users.
12+ #
13+ # Doing that in a bash script instead of doing that in the test
14+ # script allow us to easily provision the users when running that
15+ # test interactively.
16+
17+ prosodyctl register cthon98 example.com nothunter2
18+ prosodyctl register azurediamond example.com hunter2
19+ '';
20+ delUsers = pkgs: pkgs.writeScriptBin "delete-prosody-users" ''
21+ #!${pkgs.bash}/bin/bash
22+ set -e
23+
24+ # Deletes the test users.
25+ #
26+ # Doing that in a bash script instead of doing that in the test
27+ # script allow us to easily provision the users when running that
28+ # test interactively.
29+
30+ prosodyctl deluser cthon98@example.com
31+ prosodyctl deluser azurediamond@example.com
32+ '';
33+in import ../make-test-python.nix {
34+ name = "prosody-mysql";
35+ nodes = {
36+ client = { nodes, pkgs, config, ... }: {
37+ security.pki.certificateFiles = [ "${cert pkgs}/cert.pem" ];
38+ console.keyMap = "fr-bepo";
39+ networking.extraHosts = ''
40+ ${nodes.server.config.networking.primaryIPAddress} example.com
41+ ${nodes.server.config.networking.primaryIPAddress} conference.example.com
42+ ${nodes.server.config.networking.primaryIPAddress} uploads.example.com
43+ '';
44+ environment.systemPackages = [
45+ (pkgs.callPackage ./xmpp-sendmessage.nix { connectTo = nodes.server.config.networking.primaryIPAddress; })
46+ ];
47+ };
48+ server = { config, pkgs, ... }: {
49+ nixpkgs.overlays = [
50+ (self: super: {
51+ prosody = super.prosody.override {
52+ withExtraLuaPackages = p: [ p.luadbi-mysql ];
53+ };
54+ })
55+ ];
56+ security.pki.certificateFiles = [ "${cert pkgs}/cert.pem" ];
57+ console.keyMap = "fr-bepo";
58+ networking.extraHosts = ''
59+ ${config.networking.primaryIPAddress} example.com
60+ ${config.networking.primaryIPAddress} conference.example.com
61+ ${config.networking.primaryIPAddress} uploads.example.com
62+ '';
63+ networking.firewall.enable = false;
64+ environment.systemPackages = [
65+ (createUsers pkgs)
66+ (delUsers pkgs)
67+ ];
68+ services.prosody = {
69+ enable = true;
70+ ssl.cert = "${cert pkgs}/cert.pem";
71+ ssl.key = "${cert pkgs}/key.pem";
72+ virtualHosts.example = {
73+ domain = "example.com";
74+ enabled = true;
75+ ssl.cert = "${cert pkgs}/cert.pem";
76+ ssl.key = "${cert pkgs}/key.pem";
77+ };
78+ muc = [
79+ {
80+ domain = "conference.example.com";
81+ }
82+ ];
83+ uploadHttp = {
84+ domain = "uploads.example.com";
85+ };
86+ extraConfig = ''
87+ storage = "sql"
88+ sql = {
89+ driver = "MySQL";
90+ database = "prosody";
91+ host = "mysql";
92+ port = 3306;
93+ username = "prosody";
94+ password = "password123";
95+ };
96+ '';
97+ };
98+ };
99+ mysql = { config, pkgs, ... }: {
100+ networking.firewall.enable = false;
101+ services.mysql = {
102+ enable = true;
103+ initialScript = pkgs.writeText "mysql_init.sql" ''
104+ CREATE DATABASE prosody;
105+ CREATE USER 'prosody'@'server' IDENTIFIED BY 'password123';
106+ GRANT ALL PRIVILEGES ON prosody.* TO 'prosody'@'server';
107+ FLUSH PRIVILEGES;
108+ '';
109+ package = pkgs.mariadb;
110+ };
111+ };
112+ };
113+
114+ testScript = { nodes, ... }: ''
115+ # Check with mysql storage
116+ mysql.wait_for_unit("mysql.service")
117+ server.wait_for_unit("prosody.service")
118+ server.succeed('prosodyctl status | grep "Prosody is running"')
119+
120+ server.succeed("create-prosody-users")
121+ client.succeed("send-message")
122+ server.succeed("delete-prosody-users")
123+ '';
124+}
nixos/tests/xmpp/prosody.nix+1
@@ -81,6 +81,7 @@ in import ../make-test-python.nix {
8181 };
8282
8383 testScript = { nodes, ... }: ''
84+ # Check with sqlite storage
8485 server.wait_for_unit("prosody.service")
8586 server.succeed('prosodyctl status | grep "Prosody is running"')
8687
pkgs/servers/xmpp/prosody/default.nix+5−9
@@ -11,7 +11,6 @@
1111
1212with lib;
1313
14−
1514let
1615 luaEnv = lua.withPackages(p: with p; [
1716 luasocket luasec luaexpat luafilesystem luabitop luadbi-sqlite3
@@ -22,7 +21,7 @@ let
2221 );
2322in
2423stdenv.mkDerivation rec {
25− version = "0.11.12"; # also update communityModules
24+ version = "0.11.13"; # also update communityModules
2625 pname = "prosody";
2726 # The following community modules are necessary for the nixos module
2827 # prosody module to comply with XEP-0423 and provide a working
@@ -36,7 +35,7 @@ stdenv.mkDerivation rec {
3635 ];
3736 src = fetchurl {
3837 url = "https://prosody.im/downloads/source/${pname}-${version}.tar.gz";
39− sha256 = "03an206bl3h2lqcgv1wfvc2bqjq6m9vjb2idw0vyvczm43c55kan";
38+ sha256 = "sha256-OcYbNGoJtRJbYEy5aeFCBsu8uGyBFW/8a6LWJSfPBDI=";
4039 };
4140
4241 # A note to all those merging automated updates: Please also update this
@@ -44,8 +43,8 @@ stdenv.mkDerivation rec {
4443 # version.
4544 communityModules = fetchhg {
4645 url = "https://hg.prosody.im/prosody-modules";
47− rev = "bd0a1f917d98";
48− sha256 = "0figx0b0y5zfk5anf16h20y4crjmpb6bkg30vl7p0m594qnyqjcx";
46+ rev = "54fa2116bbf3";
47+ sha256 = "sha256-OKZ7tD75q8/GMXruUQ+r9l0BxzdbPHNf41fZ3fHVQVw=";
4948 };
5049
5150 nativeBuildInputs = [ makeWrapper ];
@@ -54,7 +53,6 @@ stdenv.mkDerivation rec {
5453 ]
5554 ++ withExtraLibs;
5655
57−
5856 configureFlags = [
5957 "--ostype=linux"
6058 "--with-lua-include=${luaEnv}/include"
@@ -89,9 +87,7 @@ stdenv.mkDerivation rec {
8987
9088 passthru = {
9189 communityModules = withCommunityModules;
92− tests = {
93− main = nixosTests.prosody;
94− };
90+ tests = { inherit (nixosTests) prosody prosody-mysql; };
9591 };
9692
9793 meta = {