NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
16.59k stars 13.07k forks source link

Update request: ejabberd 23.10 → 24.06 #292110

Open toastal opened 4 months ago

toastal commented 4 months ago

Notify maintainers

@abbradar @svanderburg


Note for maintainers: Please tag this issue in your PR.

I would attach this diff as a file if Microsoft GitHub didn’t disallow that. Simple version bump leads to errors.

diff --git i/pkgs/servers/xmpp/ejabberd/default.nix w/pkgs/servers/xmpp/ejabberd/default.nix
index 9e0601fbd093..109d5ce2ea1e 100644
--- i/pkgs/servers/xmpp/ejabberd/default.nix
+++ w/pkgs/servers/xmpp/ejabberd/default.nix
@@ -17,7 +17,7 @@ let
   ctlpath = lib.makeBinPath [ bash gnused gnugrep gawk coreutils util-linux procps ];
 in stdenv.mkDerivation rec {
   pname = "ejabberd";
-  version = "23.10";
+  version = "24.02";

   nativeBuildInputs = [ makeWrapper autoreconfHook ];

@@ -29,7 +29,7 @@ in stdenv.mkDerivation rec {

   src = fetchurl {
     url = "https://www.process-one.net/downloads/downloads-action.php?file=/${version}/ejabberd-${version}.tar.gz";
-    hash = "sha256-DW5/DYLZHNqJ4lddmag1B0E9ov/eObIVGASUeioPolg=";
+    hash = "sha256-ttSNO/K+82jpMh41Q2OByG14REuQQmScbEqrAIk5XAc=";
     # remember to update the deps FOD hash & its pinned ejabberd-po commit
   };

@@ -48,7 +48,7 @@ in stdenv.mkDerivation rec {
       substituteInPlace rebar.config \
         --replace \
           '{git, "https://github.com/processone/ejabberd-po", {branch, "main"}}' \
-          '{git, "https://github.com/processone/ejabberd-po", {tag, "26d6463386588d39f07027dabff3cb8dd938bf6b"}}'
+          '{git, "https://github.com/processone/ejabberd-po", {tag, "fd0e059de4c0772de37339a0a95f9a474d107b59"}}'
     '';

     configureFlags = [ "--enable-all" "--with-sqlite3=${sqlite.dev}" ];
@@ -83,7 +83,7 @@ in stdenv.mkDerivation rec {

     outputHashAlgo = "sha256";
     outputHashMode = "recursive";
-    outputHash = "sha256-HrLu3wTF+cUxpGX0yK3nbB57SRM2ND3Crlxs5/8FIwI=";
+    outputHash = "";
   };

   configureFlags = [

Add a :+1: reaction to issues you find important.

[^1]

[^1]: Please consider giving up MS GitHub or offering a non-proprietary, non-US-corporate-controlled mirror for this free software project. I wish to delete this Microsoft account in the future, but I need more projects like this to support alternative methods to send patches & contribute.

jpds commented 4 months ago

I attempted the new Elixir/Mix based approach in the linked dup, but hit another error.

jpds commented 3 months ago

@happysalada Any ideas what we can try here?

happysalada commented 3 months ago

can you paste the errors you are getting ?

jpds commented 3 months ago

With this change:

diff --git a/pkgs/servers/xmpp/ejabberd/default.nix b/pkgs/servers/xmpp/ejabberd/default.nix
index 821465ec3a52..05e2586417ba 100644
--- a/pkgs/servers/xmpp/ejabberd/default.nix
+++ b/pkgs/servers/xmpp/ejabberd/default.nix
@@ -2,6 +2,9 @@
 , erlang, openssl, expat, libyaml, bash, gnused, gnugrep, coreutils, util-linux, procps, gd
 , flock, autoreconfHook
 , gawk
+, hex
+, elixir
+, rebar3
 , nixosTests
 , withMysql ? false
 , withPgsql ? false
@@ -17,7 +20,7 @@ let
   ctlpath = lib.makeBinPath [ bash gnused gnugrep gawk coreutils util-linux procps ];
 in stdenv.mkDerivation rec {
   pname = "ejabberd";
-  version = "23.10";
+  version = "24.02";

   nativeBuildInputs = [ makeWrapper autoreconfHook ];

@@ -29,7 +32,7 @@ in stdenv.mkDerivation rec {

   src = fetchurl {
     url = "https://www.process-one.net/downloads/downloads-action.php?file=/${version}/ejabberd-${version}.tar.gz";
-    hash = "sha256-DW5/DYLZHNqJ4lddmag1B0E9ov/eObIVGASUeioPolg=";
+    hash = "sha256-ttSNO/K+82jpMh41Q2OByG14REuQQmScbEqrAIk5XAc=";
     # remember to update the deps FOD hash & its pinned ejabberd-po commit
   };

@@ -48,13 +51,13 @@ in stdenv.mkDerivation rec {
       substituteInPlace rebar.config \
         --replace \
           '{git, "https://github.com/processone/ejabberd-po", {branch, "main"}}' \
-          '{git, "https://github.com/processone/ejabberd-po", {tag, "26d6463386588d39f07027dabff3cb8dd938bf6b"}}'
+          '{git, "https://github.com/processone/ejabberd-po", {tag, "fd0e059de4c0772de37339a0a95f9a474d107b59"}}'
     '';

     configureFlags = [ "--enable-all" "--with-sqlite3=${sqlite.dev}" ];

     nativeBuildInputs = [
-      git erlang openssl expat libyaml sqlite pam zlib autoreconfHook
+      git erlang openssl expat libyaml sqlite pam zlib autoreconfHook rebar3 elixir hex
     ];

     GIT_SSL_CAINFO = "${cacert}/etc/ssl/certs/ca-bundle.crt";
@@ -83,7 +86,7 @@ in stdenv.mkDerivation rec {

     outputHashAlgo = "sha256";
     outputHashMode = "recursive";
-    outputHash = "sha256-HrLu3wTF+cUxpGX0yK3nbB57SRM2ND3Crlxs5/8FIwI=";
+    outputHash = "";
   };

   configureFlags = [
@@ -97,6 +100,7 @@ in stdenv.mkDerivation rec {
   ] ++ lib.optional withSqlite "--with-sqlite3=${sqlite.dev}";

   enableParallelBuilding = true;
+  makeFlags = [ "prod" ];

   postPatch = ''
     cp -r $deps deps

I get these errors:

source root is ejabberd-24.02
setting SOURCE_DATE_EPOCH to timestamp 1709026375 of file ejabberd-24.02/vars.config.in
Running phase: patchPhase
substituteStream(): WARNING: '--replace' is deprecated, use --replace-{fail,warn,quiet}. (file 'rebar.config')
Running phase: autoreconfPhase
autoreconf: export WARNINGS=
autoreconf: Entering directory '.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal --force
autoreconf: configure.ac: tracing
autoreconf: configure.ac: not using Libtool
autoreconf: configure.ac: not using Intltool
autoreconf: configure.ac: not using Gtkdoc
autoreconf: running: /nix/store/r3jjjnf7fmbhw3cmm1fr2s9q1zcpv8ji-autoconf-2.72/bin/autoconf --force
autoreconf: configure.ac: not using Autoheader
autoreconf: configure.ac: not using Automake
autoreconf: './install-sh' is updated
autoreconf: Leaving directory '.'
Running phase: updateAutotoolsGnuConfigScriptsPhase
Running phase: configurePhase
patching script interpreter paths in ./configure
./configure: interpreter directive changed from "#! /bin/sh" to "/nix/store/a1s263pmsci9zykm5xcdf7x9rv26w6d5-bash-5.2p26/bin/sh"
configure flags: --prefix=/nix/store/pjrxa9hp072hcqc6qw90g6k4db72b57q-ejabberd-deps-24.02 --enable-all --with-sqlite3=/nix/store/p00xm6dw9r1acssqfkl7111l5n4nz6vl-sqlite-3.45.2-dev
checking whether make sets $(MAKE)... yes
checking for gawk... gawk
checking for a BSD-compatible install... /nix/store/ifzwv2xqwdnv1gz87rxkizi67py5p3vj-coreutils-9.4/bin/install -c
checking for a race-free mkdir -p... /nix/store/ifzwv2xqwdnv1gz87rxkizi67py5p3vj-coreutils-9.4/bin/mkdir -p
checking for a sed that does not truncate output... /nix/store/237dff1igc3v09p9r23a37yw8dr04bv6-gnused-4.9/bin/sed
checking for erl... /nix/store/95hfr266rv0vqp0253lj89z4vliwwgd7-erlang-25.3.2.10/bin/erl
checking for erlc... /nix/store/95hfr266rv0vqp0253lj89z4vliwwgd7-erlang-25.3.2.10/bin/erlc
checking for epmd... /nix/store/95hfr266rv0vqp0253lj89z4vliwwgd7-erlang-25.3.2.10/bin/epmd
checking for rebar... no
checking for rebar3... /nix/store/hzfnxphsjxiw5zvmz9pz6kw0v81x4ggq-rebar3-3.23.0/bin/rebar3
checking for elixir... /nix/store/wj6gipl59wpyyrb0zcj32sfjx5fmi1mf-elixir-1.16.2/bin/elixir
checking for iex... /nix/store/wj6gipl59wpyyrb0zcj32sfjx5fmi1mf-elixir-1.16.2/bin/iex
checking for mix... /nix/store/wj6gipl59wpyyrb0zcj32sfjx5fmi1mf-elixir-1.16.2/bin/mix
checking for erl... (cached) /nix/store/95hfr266rv0vqp0253lj89z4vliwwgd7-erlang-25.3.2.10/bin/erl
checking for erlc... (cached) /nix/store/95hfr266rv0vqp0253lj89z4vliwwgd7-erlang-25.3.2.10/bin/erlc
checking for Erlang/OTP root directory... /nix/store/95hfr266rv0vqp0253lj89z4vliwwgd7-erlang-25.3.2.10/lib/erlang
checking for escript... /nix/store/95hfr266rv0vqp0253lj89z4vliwwgd7-erlang-25.3.2.10/lib/erlang/bin/escript
checking for make... make
checking Erlang/OTP version... ok
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether gcc accepts -g... yes
checking for gcc option to enable C11 features... none needed
checking for SQLite3 library >= 3.6.19... yes
grep: warning: stray \ before "
build tool to use (change using --with-rebar): /nix/store/wj6gipl59wpyyrb0zcj32sfjx5fmi1mf-elixir-1.16.2/bin/mix
configure: creating ./config.status
config.status: creating Makefile
config.status: creating vars.config
Running phase: buildPhase
build flags: SHELL=/nix/store/a1s263pmsci9zykm5xcdf7x9rv26w6d5-bash-5.2p26/bin/bash deps
rm -rf _build/dev/lib/.got
rm -rf _build/dev/lib/.built
/nix/store/ifzwv2xqwdnv1gz87rxkizi67py5p3vj-coreutils-9.4/bin/mkdir -p _build/dev/lib
/nix/store/wj6gipl59wpyyrb0zcj32sfjx5fmi1mf-elixir-1.16.2/bin/mix deps.get && :> _build/dev/lib/.got
warning: the VM is running with native name encoding of latin1 which may cause Elixir to malfunction as it expects utf8. Please ensure your locale is set to UTF-8 (which can be verified by running "locale" in your shell) or set the ELIXIR_>
** (File.Error) could not make directory (with -p) "/homeless-shelter/.mix/archives/hex-2.0.6": no such file or directory
    (elixir 1.16.2) lib/file.ex:345: File.mkdir_p!/1
    (mix 1.16.2) lib/mix/tasks/archive.install.ex:122: Mix.Tasks.Archive.Install.install/3
    (mix 1.16.2) lib/mix/local/installer.ex:107: Mix.Local.Installer.local_install/3
    (mix 1.16.2) lib/mix/dep/loader.ex:188: Mix.Dep.Loader.with_scm_and_app/5
    (mix 1.16.2) lib/mix/dep/loader.ex:141: Mix.Dep.Loader.to_dep/4
    (elixir 1.16.2) lib/enum.ex:1700: Enum."-map/2-lists^map/1-1-"/2
    (mix 1.16.2) lib/mix/dep/loader.ex:364: Mix.Dep.Loader.mix_children/3
    (mix 1.16.2) lib/mix/dep/loader.ex:18: Mix.Dep.Loader.children/1
make: *** [Makefile:211: _build/dev/lib/.got] Error 1
happysalada commented 3 months ago

sorry looking at the error I don't have any idea of what it could be. I hope you solve it though.

chuangzhu commented 2 months ago

@jpds Based on your work, I was able to get deps build:

diff --git a/pkgs/servers/xmpp/ejabberd/default.nix b/pkgs/servers/xmpp/ejabberd/default.nix
index 821465ec3a52..b1aaee54406e 100644
--- a/pkgs/servers/xmpp/ejabberd/default.nix
+++ b/pkgs/servers/xmpp/ejabberd/default.nix
@@ -2,6 +2,9 @@
 , erlang, openssl, expat, libyaml, bash, gnused, gnugrep, coreutils, util-linux, procps, gd
 , flock, autoreconfHook
 , gawk
+, hex
+, elixir
+, rebar3
 , nixosTests
 , withMysql ? false
 , withPgsql ? false
@@ -17,9 +20,9 @@ let
   ctlpath = lib.makeBinPath [ bash gnused gnugrep gawk coreutils util-linux procps ];
 in stdenv.mkDerivation rec {
   pname = "ejabberd";
-  version = "23.10";
+  version = "24.02";

-  nativeBuildInputs = [ makeWrapper autoreconfHook ];
+  nativeBuildInputs = [ makeWrapper autoreconfHook rebar3 hex ];

   buildInputs = [ erlang openssl expat libyaml gd ]
     ++ lib.optional withSqlite sqlite
@@ -29,7 +32,7 @@ in stdenv.mkDerivation rec {

   src = fetchurl {
     url = "https://www.process-one.net/downloads/downloads-action.php?file=/${version}/ejabberd-${version}.tar.gz";
-    hash = "sha256-DW5/DYLZHNqJ4lddmag1B0E9ov/eObIVGASUeioPolg=";
+    hash = "sha256-ttSNO/K+82jpMh41Q2OByG14REuQQmScbEqrAIk5XAc=";
     # remember to update the deps FOD hash & its pinned ejabberd-po commit
   };

@@ -48,30 +51,31 @@ in stdenv.mkDerivation rec {
       substituteInPlace rebar.config \
         --replace \
           '{git, "https://github.com/processone/ejabberd-po", {branch, "main"}}' \
-          '{git, "https://github.com/processone/ejabberd-po", {tag, "26d6463386588d39f07027dabff3cb8dd938bf6b"}}'
+          '{git, "https://github.com/processone/ejabberd-po", {tag, "fd0e059de4c0772de37339a0a95f9a474d107b59"}}'
     '';

     configureFlags = [ "--enable-all" "--with-sqlite3=${sqlite.dev}" ];

     nativeBuildInputs = [
-      git erlang openssl expat libyaml sqlite pam zlib autoreconfHook
+      erlang openssl expat libyaml sqlite pam zlib autoreconfHook rebar3 elixir hex
     ];

     GIT_SSL_CAINFO = "${cacert}/etc/ssl/certs/ca-bundle.crt";

     makeFlags = [ "deps" ];

+    preBuild = ''
+      export MIX_HOME="$(mktemp -d)" HEX_HOME="$(mktemp -d)"
+    '';
+
     installPhase = ''
       for i in deps/*; do
-        ( cd $i
-          git reset --hard
-          git clean -ffdx
-          git describe --always --tags > .rev
-          rm -rf .git .github
-        )
+        [ -d $i ] && {
+          pushd $i
+          rm -rf .git .github config.status config.log
+          popd
+        }
       done
-      # not a typo; comes from `make deps`
-      rm deps/.got

       cp -r deps $out
     '';
@@ -83,7 +87,7 @@ in stdenv.mkDerivation rec {

     outputHashAlgo = "sha256";
     outputHashMode = "recursive";
-    outputHash = "sha256-HrLu3wTF+cUxpGX0yK3nbB57SRM2ND3Crlxs5/8FIwI=";
+    outputHash = "sha256-7PC5cLg692aa1NrWEhokqs/FYMRBa5B6dwLiO3/41gI=";
   };

   configureFlags = [
@@ -104,6 +108,10 @@ in stdenv.mkDerivation rec {
     patchShebangs .
   '';

+  preBuild = ''
+    export REBAR_CACHE_DIR="$(mktemp -d)"
+  '';
+
   postInstall = ''
     sed -i \
       -e '2iexport PATH=${ctlpath}:$PATH' \

But I got stuck on https://github.com/erlang/rebar3/issues/1281:

ejabberd> /nix/store/41vxrrg5jhakp3yg0dd4wr7mphij6a39-rebar3-3.22.1/bin/rebar3 get-deps && :> _build/default/lib/.got
ejabberd> ===> Analyzing applications...
ejabberd> ===> Compiling configure_deps
ejabberd> ===> Failed to update package rebar3_hex from repo hexpm
ejabberd> ===> Errors loading plugin rebar3_hex. Run rebar3 with DEBUG=1 set to see errors.
ejabberd> ===> Failed to update package provider_asn1 from repo hexpm
ejabberd> ===> Errors loading plugin {provider_asn1,"0.2.0"}. Run rebar3 with DEBUG=1 set to see errors.
ejabberd> ===> Failed to update package rebar3_hex from repo hexpm
ejabberd> ===> Errors loading plugin rebar3_hex. Run rebar3 with DEBUG=1 set to see errors.
ejabberd> ===> Failed to update package provider_asn1 from repo hexpm
ejabberd> ===> Errors loading plugin {provider_asn1,"0.2.0"}. Run rebar3 with DEBUG=1 set to see errors.
ejabberd> ===> Verifying dependencies...
ejabberd> ===> Failed to update package base64url from repo hexpm
ejabberd> ===> Package not found in any repo: base64url 1.0.1
ejabberd> make: *** [Makefile:211: _build/default/lib/.got] Error 1

https://github.com/erlang/rebar3/pull/2643#issuecomment-966432404 mentioned that one can use the rebar3_path_deps plugin, but fetching plugins also requires internet access. I guess the next thing I will try is https://github.com/erlang-nix/rebar3_nix, which is already used in elvis-erlang, erlang-ls and rebar3 itself

chuangzhu commented 2 months ago

Another attempt, using rebar3_nix: https://gist.github.com/chuangzhu/e40c9cde919925fba25a3cb4da514e9c

It builds, but ejabberdctl crashes

chuangzhu commented 4 weeks ago

OK I figured it out. It's just because we have an override { erlang = erlang_24; } in all-packages.nix, some ABI mismatch I guess. By removing it everything seems to work. I'll do some clean up and testing, then open a PR asap

$ ./result/bin/ejabberdctl 
Failed RPC connection to the node ejabberd@localhost: nodedown

Commands to start an ejabberd node:
  start            Start in server mode
  foreground       Start in server mode (attached)
  foreground-quiet Start in server mode (attached), show only critical messages
  live             Start in interactive mode, with Erlang shell
  iexlive          Start in interactive mode, with Elixir shell

Commands to interact with a running ejabberd node:
  debug            Attach an interactive Erlang shell to a running node
  iexdebug         Attach an interactive Elixir shell to a running node
  etop             Attach to a running node and start Erlang Top
  ping             Send ping to the node, returns pong or pang
  started|stopped  Wait for the node to fully start|stop

Optional parameters when starting an ejabberd node:
  --config-dir dir   Config ejabberd:    /nix/store/p4c84sfmr1isnzbxb17f1whwvdpgpjh5-ejabberd-24.02/etc/ejabberd
  --config file      Config ejabberd:    /nix/store/p4c84sfmr1isnzbxb17f1whwvdpgpjh5-ejabberd-24.02/etc/ejabberd/ejabberd.yml
  --ctl-config file  Config ejabberdctl: /nix/store/p4c84sfmr1isnzbxb17f1whwvdpgpjh5-ejabberd-24.02/etc/ejabberd/ejabberdctl.cfg
  --logs dir         Directory for logs: /nix/store/p4c84sfmr1isnzbxb17f1whwvdpgpjh5-ejabberd-24.02/var/log/ejabberd
  --spool dir        Database spool dir: /nix/store/p4c84sfmr1isnzbxb17f1whwvdpgpjh5-ejabberd-24.02/var/lib/ejabberd
  --node nodename    ejabberd node name: ejabberd@localhost
chuangzhu commented 4 weeks ago

320617