Unverified Commit a71d327d authored by Yt's avatar Yt Committed by GitHub
Browse files

ejabberd: 23.10 -> 24.07 (#320617)

parents d96ebab0 8fefd4d6
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
let
  cert = pkgs: pkgs.runCommand "selfSignedCerts" { buildInputs = [ pkgs.openssl ]; } ''
    openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -nodes -subj '/CN=example.com/CN=muc.example.com' -days 36500
    mkdir -p $out
    cp key.pem cert.pem $out
  '';
in
import ../make-test-python.nix ({ pkgs, ... }: {
  name = "ejabberd";
  meta = with pkgs.lib.maintainers; {
@@ -5,6 +12,7 @@ import ../make-test-python.nix ({ pkgs, ... }: {
  };
  nodes = {
    client = { nodes, pkgs, ... }: {
      security.pki.certificateFiles = [ "${cert pkgs}/cert.pem" ];
      networking.extraHosts = ''
        ${nodes.server.config.networking.primaryIPAddress} example.com
      '';
@@ -14,6 +22,7 @@ import ../make-test-python.nix ({ pkgs, ... }: {
      ];
    };
    server = { config, pkgs, ... }: {
      security.pki.certificateFiles = [ "${cert pkgs}/cert.pem" ];
      networking.extraHosts = ''
        ${config.networking.primaryIPAddress} example.com
      '';
@@ -23,6 +32,7 @@ import ../make-test-python.nix ({ pkgs, ... }: {
        configFile = "/etc/ejabberd.yml";
      };

      systemd.services.ejabberd.serviceConfig.TimeoutStartSec = "15min";
      environment.etc."ejabberd.yml" = {
        user = "ejabberd";
        mode = "0600";
@@ -40,6 +50,7 @@ import ../make-test-python.nix ({ pkgs, ... }: {
              max_stanza_size: 65536
              shaper: c2s_shaper
              access: c2s
              starttls: true
            -
              port: 5269
              ip: "::"
@@ -56,6 +67,10 @@ import ../make-test-python.nix ({ pkgs, ... }: {
              request_handlers:
                "/upload": mod_http_upload

          certfiles:
            - ${cert pkgs}/key.pem
            - ${cert pkgs}/cert.pem

          ## Disabling digest-md5 SASL authentication. digest-md5 requires plain-text
          ## password storage (see auth_password_format option).
          disable_sasl_mechanisms: "digest-md5"
+109 −69
Original line number Diff line number Diff line
{ stdenv, writeScriptBin, makeWrapper, lib, fetchurl, git, cacert, libpng, libjpeg, libwebp
{ stdenv, makeWrapper, lib, fetchurl, libpng, libjpeg, libwebp
, erlang, openssl, expat, libyaml, bash, gnused, gnugrep, coreutils, util-linux, procps, gd
, flock, autoreconfHook
, autoreconfHook
, gawk
, rebar3WithPlugins
, fetchFromGitHub
, fetchgit
, fetchHex
, beamPackages
, nixosTests
, withMysql ? false
, withPgsql ? false
, withSqlite ? false, sqlite
, withPam ? false, pam
, withZlib ? true, zlib
, withSip ? false
, withLua ? false
, withTools ? false
, withRedis ? false
, withImagemagick ? false, imagemagick
@@ -15,75 +22,107 @@

let
  ctlpath = lib.makeBinPath [ bash gnused gnugrep gawk coreutils util-linux procps ];
in stdenv.mkDerivation rec {
  pname = "ejabberd";
  version = "23.10";

  nativeBuildInputs = [ makeWrapper autoreconfHook ];

  buildInputs = [ erlang openssl expat libyaml gd ]
    ++ lib.optional withSqlite sqlite
    ++ lib.optional withPam pam
    ++ lib.optional withZlib zlib
  ;

  src = fetchurl {
    url = "https://www.process-one.net/downloads/downloads-action.php?file=/${version}/ejabberd-${version}.tar.gz";
    hash = "sha256-DW5/DYLZHNqJ4lddmag1B0E9ov/eObIVGASUeioPolg=";
    # remember to update the deps FOD hash & its pinned ejabberd-po commit
  provider_asn1 = beamPackages.buildRebar3 {
    name = "provider_asn1";
    version = "0.3.0";
    src = fetchHex {
      pkg = "provider_asn1";
      version = "0.3.0";
      sha256 = "sha256-MuelWYZi01rBut8jM6a5alMZizPGZoBE/LveSRu/+wU=";
    };

  passthru.tests = {
    inherit (nixosTests) ejabberd;
    beamDeps = [ ];
  };
  rebar3_hex = beamPackages.buildRebar3 {
    name = "rebar3_hex";
    version = "7.0.7";
    src = fetchHex {
      pkg = "rebar3_hex";
      version = "7.0.7";
      sha256 = "sha256-1S2igSwiInATUgULZ1E6e2dK6YI5gvRffHRfF1Gg5Ok=";
    };
    beamDeps = [ ];
  };

  deps = stdenv.mkDerivation {
    pname = "ejabberd-deps";

    inherit src version;
  allBeamDeps = import ./rebar-deps.nix {  # TODO(@chuangzhu) add updateScript
    inherit fetchHex fetchgit fetchFromGitHub;
    builder = lib.makeOverridable beamPackages.buildRebar3;

    overrides = final: prev: {
      jiffy = prev.jiffy.override { buildPlugins = [ beamPackages.pc ]; };
      cache_tab = prev.cache_tab.override { buildPlugins = [ beamPackages.pc ]; };
      mqtree = prev.mqtree.override { buildPlugins = [ beamPackages.pc ]; };
      stringprep = prev.stringprep.override { buildPlugins = [ beamPackages.pc ]; };
      p1_acme = prev.p1_acme.override { buildPlugins = [ beamPackages.pc ]; };
      eimp = prev.eimp.override {
        buildInputs = [ gd libwebp libpng libjpeg ];
        buildPlugins = [ beamPackages.pc ];
      };
      fast_tls = prev.fast_tls.override {
        buildInputs = [ openssl ];
        buildPlugins = [ beamPackages.pc ];
      };
      fast_xml = prev.fast_xml.override {
        buildInputs = [ expat ];
        buildPlugins = [ beamPackages.pc ];
      };
      fast_yaml = prev.fast_yaml.override {
        buildInputs = [ libyaml ];
        buildPlugins = [ beamPackages.pc ];
      };
      xmpp = prev.xmpp.override {
        buildPlugins = [ beamPackages.pc provider_asn1 ];
      };
      # Optional deps
      sqlite3 = prev.sqlite3.override {
        buildInputs = [ sqlite ];
        buildPlugins = [ beamPackages.pc ];
      };
      p1_mysql = prev.p1_acme.override { buildPlugins = [ beamPackages.pc ]; };
      epam = prev.epam.override {
        buildInputs = [ pam ];
        buildPlugins = [ beamPackages.pc ];
      };
      esip = prev.esip.override { buildPlugins = [ beamPackages.pc ]; };
      ezlib = prev.ezlib.override {
        buildInputs = [ zlib ];
        buildPlugins = [ beamPackages.pc ];
      };
    };
  };

    # pin ejabberd-po dep
    # update: curl -L api.github.com/repos/processone/ejabberd-po/branches/main | jq .commit.sha -r
    postPatch = ''
      substituteInPlace rebar.config \
        --replace \
          '{git, "https://github.com/processone/ejabberd-po", {branch, "main"}}' \
          '{git, "https://github.com/processone/ejabberd-po", {tag, "26d6463386588d39f07027dabff3cb8dd938bf6b"}}'
    '';
  beamDeps = builtins.removeAttrs allBeamDeps [ "sqlite3" "p1_pgsql" "p1_mysql" "luerl" "esip" "eredis" "epam" "ezlib" ];

    configureFlags = [ "--enable-all" "--with-sqlite3=${sqlite.dev}" ];
in stdenv.mkDerivation rec {
  pname = "ejabberd";
  version = "24.07";

  nativeBuildInputs = [
      git erlang openssl expat libyaml sqlite pam zlib autoreconfHook
    makeWrapper
    autoreconfHook
    (rebar3WithPlugins { plugins = [ provider_asn1 rebar3_hex ]; })
  ];

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

    makeFlags = [ "deps" ];

    installPhase = ''
      for i in deps/*; do
        ( cd $i
          git reset --hard
          git clean -ffdx
          git describe --always --tags > .rev
          rm -rf .git .github
        )
      done
      # not a typo; comes from `make deps`
      rm deps/.got

      cp -r deps $out
    '';
  buildInputs = [ erlang ]
    ++ builtins.attrValues beamDeps
    ++ lib.optional withMysql allBeamDeps.p1_mysql
    ++ lib.optional withPgsql allBeamDeps.p1_pgsql
    ++ lib.optional withSqlite allBeamDeps.sqlite3
    ++ lib.optional withPam allBeamDeps.epam
    ++ lib.optional withZlib allBeamDeps.ezlib
    ++ lib.optional withSip allBeamDeps.esip
    ++ lib.optional withLua allBeamDeps.luerl
    ++ lib.optional withRedis allBeamDeps.eredis
  ;

    dontPatchELF = true;
    dontStrip = true;
    # avoid /nix/store references in the source
    dontPatchShebangs = true;
  src = fetchurl {
    url = "https://www.process-one.net/downloads/downloads-action.php?file=/${version}/ejabberd-${version}.tar.gz";
    hash = "sha256-wPt0asuoGl20Hel8A5aMH2gaE7G2waiVtxguM4IMGNk=";
    # remember to update rebar-deps.nix
  };

    outputHashAlgo = "sha256";
    outputHashMode = "recursive";
    outputHash = "sha256-HrLu3wTF+cUxpGX0yK3nbB57SRM2ND3Crlxs5/8FIwI=";
  passthru.tests = {
    inherit (nixosTests) ejabberd;
  };

  configureFlags = [
@@ -92,6 +131,8 @@ in stdenv.mkDerivation rec {
    (lib.enableFeature withSqlite "sqlite")
    (lib.enableFeature withPam "pam")
    (lib.enableFeature withZlib "zlib")
    (lib.enableFeature withSip "sip")
    (lib.enableFeature withLua "lua")
    (lib.enableFeature withTools "tools")
    (lib.enableFeature withRedis "redis")
  ] ++ lib.optional withSqlite "--with-sqlite3=${sqlite.dev}";
@@ -99,21 +140,20 @@ in stdenv.mkDerivation rec {
  enableParallelBuilding = true;

  postPatch = ''
    cp -r $deps deps
    chmod -R +w deps
    patchShebangs .
    mkdir -p _build/default/lib
    touch _build/default/lib/.got
    touch _build/default/lib/.built
  '';

  REBAR_IGNORE_DEPS = 1;

  postInstall = ''
    sed -i \
      -e '2iexport PATH=${ctlpath}:$PATH' \
      -e 's,\(^ *FLOCK=\).*,\1${flock}/bin/flock,' \
      -e 's,\(^ *JOT=\).*,\1,' \
      -e 's,\(^ *CONNLOCKDIR=\).*,\1/var/lock/ejabberdctl,' \
      -e "s,\(^ *ERL_LIBS=.*\),\1:$ERL_LIBS," \
      $out/sbin/ejabberdctl
    wrapProgram $out/lib/eimp-*/priv/bin/eimp --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ libpng libjpeg libwebp ]}"
    ${lib.optionalString withImagemagick ''wrapProgram $out/lib/ejabberd-*/priv/bin/captcha.sh --prefix PATH : "${lib.makeBinPath [ imagemagick ]}"''}
    rm $out/bin/{mix,iex,elixir}
  '';

  meta = with lib; {
@@ -122,6 +162,6 @@ in stdenv.mkDerivation rec {
    license = licenses.gpl2Plus;
    homepage = "https://www.ejabberd.im";
    platforms = platforms.linux;
    maintainers = with maintainers; [ sander abbradar ];
    maintainers = with maintainers; [ sander abbradar chuangzhu ];
  };
}
+278 −0
Original line number Diff line number Diff line
# Generated by rebar3_nix
let fetchOnly = { src, ... }: src;
in { builder ? fetchOnly, fetchHex, fetchgit, fetchFromGitHub, overrides ? (x: y: { }) }:
let
  self = packages // (overrides self packages);
  packages = with self; {
    unicode_util_compat = builder {
      name = "unicode_util_compat";
      version = "0.7.0";
      src = fetchHex {
        pkg = "unicode_util_compat";
        version = "0.7.0";
        sha256 = "sha256-Je7m1n32GWDPanlCOVZlmbCeF+Zo03ACR7xJhjgVJSE=";
      };
      beamDeps = [ ];
    };
    jiffy = builder {
      name = "jiffy";
      version = "1.1.2";
      src = fetchHex {
        pkg = "jiffy";
        version = "1.1.2";
        sha256 = "sha256-u2G8Qqcgu9M8sJpBDki7eaYQEsdMuLPnXybZiEhc84E=";
      };
      beamDeps = [ ];
    };
    base64url = builder {
      name = "base64url";
      version = "1.0.1";
      src = fetchHex {
        pkg = "base64url";
        version = "1.0.1";
        sha256 = "sha256-+bOt1HMaAqmwQQOYtHWzPnVmppU2Ujemve4btEdxn1w=";
      };
      beamDeps = [ ];
    };
    yconf = builder {
      name = "yconf";
      version = "1.0.16";
      src = fetchHex {
        pkg = "yconf";
        version = "1.0.16";
        sha256 = "sha256-6UeBMnPzhxHHsuWo5KzJpRx7voVPdEo0X2AwCzhYbIk=";
      };
      beamDeps = [ fast_yaml ];
    };
    xmpp = builder {
      name = "xmpp";
      version = "1.8.3";
      src = fetchHex {
        pkg = "xmpp";
        version = "1.8.3";
        sha256 = "sha256-7XAGX5qJqBjc/0O3TAgMnn9PFBThBRvt23KA24Ca9xE=";
      };
      beamDeps = [ ezlib fast_tls fast_xml idna p1_utils stringprep ];
    };
    stun = builder {
      name = "stun";
      version = "1.2.14";
      src = fetchHex {
        pkg = "stun";
        version = "1.2.14";
        sha256 = "sha256-4TSAext6jf/ZTmTu/uAOZce0BC89FOFvj0NWbSA3FYM=";
      };
      beamDeps = [ fast_tls p1_utils ];
    };
    stringprep = builder {
      name = "stringprep";
      version = "1.0.30";
      src = fetchHex {
        pkg = "stringprep";
        version = "1.0.30";
        sha256 = "sha256-9vybM4SgOHeDD4my84WAyvP0onRIpKMz1qjDl1wiC5o=";
      };
      beamDeps = [ p1_utils ];
    };
    sqlite3 = builder {
      name = "sqlite3";
      version = "1.1.15";
      src = fetchHex {
        pkg = "sqlite3";
        version = "1.1.15";
        sha256 = "sha256-PAuk4TMiwq1J3k4t3SgxE2at3lS+ro26nZ44iPadKFc=";
      };
      beamDeps = [ ];
    };
    pkix = builder {
      name = "pkix";
      version = "1.0.10";
      src = fetchHex {
        pkg = "pkix";
        version = "1.0.10";
        sha256 = "sha256-4CFk+DCUyxJMQbGrKJiKYV1Uua3DhXXwDxmll6OsXQ4=";
      };
      beamDeps = [ ];
    };
    p1_utils = builder {
      name = "p1_utils";
      version = "1.0.26";
      src = fetchHex {
        pkg = "p1_utils";
        version = "1.0.26";
        sha256 = "sha256-0DeejBFWuYvWT4Epwd4CL8yk8v23SGznO/DtLDN2sEw=";
      };
      beamDeps = [ ];
    };
    p1_pgsql = builder {
      name = "p1_pgsql";
      version = "1.1.27";
      src = fetchHex {
        pkg = "p1_pgsql";
        version = "1.1.27";
        sha256 = "sha256-jk0adgLLaHgOVdidxamy4arKP08e49GiXy+MPSNk/7k=";
      };
      beamDeps = [ xmpp ];
    };
    p1_oauth2 = builder {
      name = "p1_oauth2";
      version = "0.6.14";
      src = fetchHex {
        pkg = "p1_oauth2";
        version = "0.6.14";
        sha256 = "sha256-H9OsR05Dci2dWofG34029pjth697uBy7tmNhRR2Zro8=";
      };
      beamDeps = [ ];
    };
    p1_mysql = builder {
      name = "p1_mysql";
      version = "1.0.24";
      src = fetchHex {
        pkg = "p1_mysql";
        version = "1.0.24";
        sha256 = "sha256-8FiGX2Qlf1B6LGpa/zabE3XbyzCz1CWNrU8bPq/7ZV8=";
      };
      beamDeps = [ ];
    };
    p1_acme = builder {
      name = "p1_acme";
      version = "1.0.23";
      src = fetchHex {
        pkg = "p1_acme";
        version = "1.0.23";
        sha256 = "sha256-jOGW8m49IuoQt4CRIpUEZYeMEn+Adn4yUgeu1+jQ3Vk=";
      };
      beamDeps = [ base64url idna jiffy jose yconf ];
    };
    mqtree = builder {
      name = "mqtree";
      version = "1.0.17";
      src = fetchHex {
        pkg = "mqtree";
        version = "1.0.17";
        sha256 = "sha256-X+i3z4+8R4PQ/OuUZUrCu/MkKljNA5fSSd7YrgIb4qM=";
      };
      beamDeps = [ p1_utils ];
    };
    luerl = builder {
      name = "luerl";
      version = "1.2.0";
      src = fetchHex {
        pkg = "luerl";
        version = "1.2.0";
        sha256 = "sha256-nK/U9glP8PWp0nj9gdYNPgJsggvftsrNSxvZCfIbUl0=";
      };
      beamDeps = [ ];
    };
    jose = builder {
      name = "jose";
      version = "1.11.10";
      src = fetchHex {
        pkg = "jose";
        version = "1.11.10";
        sha256 = "sha256-DWzTb/i6F02ykUj8EStYQhhraKkM6fwrPsOv52WT5hQ=";
      };
      beamDeps = [ ];
    };
    idna = builder {
      name = "idna";
      version = "6.1.1";
      src = fetchHex {
        pkg = "idna";
        version = "6.1.1";
        sha256 = "sha256-kjdut4lEEu0ZrEdeSob3tBPBufu1vRbczVeTQVeUTOo=";
      };
      beamDeps = [ unicode_util_compat ];
    };
    fast_yaml = builder {
      name = "fast_yaml";
      version = "1.0.37";
      src = fetchHex {
        pkg = "fast_yaml";
        version = "1.0.37";
        sha256 = "sha256-jehochv34hckFPfTFI7eDzySK0lkVc1iXdXEQpUVp2k=";
      };
      beamDeps = [ p1_utils ];
    };
    fast_xml = builder {
      name = "fast_xml";
      version = "1.1.52";
      src = fetchHex {
        pkg = "fast_xml";
        version = "1.1.52";
        sha256 = "sha256-eVGSOQ4G0rZQFqaZC7+lcn9KJtKRSAixw8mjLu3NG/0=";
      };
      beamDeps = [ p1_utils ];
    };
    fast_tls = builder {
      name = "fast_tls";
      version = "1.1.21";
      src = fetchHex {
        pkg = "fast_tls";
        version = "1.1.21";
        sha256 = "sha256-ExVCkTk3Al5IzYCqgfADWWhtVQG3ViHnICaoe1IpUFs=";
      };
      beamDeps = [ p1_utils ];
    };
    ezlib = builder {
      name = "ezlib";
      version = "1.0.13";
      src = fetchHex {
        pkg = "ezlib";
        version = "1.0.13";
        sha256 = "sha256-nuYqs/jtVaD9EalWn8uORYaD+VV1QXJyGSsGnwkqv7s=";
      };
      beamDeps = [ p1_utils ];
    };
    esip = builder {
      name = "esip";
      version = "1.0.54";
      src = fetchHex {
        pkg = "esip";
        version = "1.0.54";
        sha256 = "sha256-gYevgZ1yWc2t2vaXJsI572BMmwsCmKXy0+aHv14iN+4=";
      };
      beamDeps = [ fast_tls p1_utils stun ];
    };
    eredis = builder {
      name = "eredis";
      version = "1.2.0";
      src = fetchHex {
        pkg = "eredis";
        version = "1.2.0";
        sha256 = "sha256-2bWr7ywsirqPMqoBggPgs9yLEVd3OyVKsdTCACMX8eE=";
      };
      beamDeps = [ ];
    };
    epam = builder {
      name = "epam";
      version = "1.0.14";
      src = fetchHex {
        pkg = "epam";
        version = "1.0.14";
        sha256 = "sha256-LzRJ5yiFpypsKoQ/VhrdD8L3DXoh9hRWkwpUdHPU2Yk=";
      };
      beamDeps = [ ];
    };
    eimp = builder {
      name = "eimp";
      version = "1.0.23";
      src = fetchHex {
        pkg = "eimp";
        version = "1.0.23";
        sha256 = "sha256-kHx4ACPLKJPk/Evb5qTwLDVZE4Yqxn8OzCZgXoFrYoo=";
      };
      beamDeps = [ p1_utils ];
    };
    cache_tab = builder {
      name = "cache_tab";
      version = "1.0.31";
      src = fetchHex {
        pkg = "cache_tab";
        version = "1.0.31";
        sha256 = "sha256-hYK2CkoJskfvhjVbqeB/zp4R7cA0WndckXH5cccrY1E=";
      };
      beamDeps = [ p1_utils ];
    };
  };
in self
+1 −1
Original line number Diff line number Diff line
@@ -24186,7 +24186,7 @@ with pkgs;
  etcd_3_4 = callPackage ../servers/etcd/3.4.nix { };
  etcd_3_5 = callPackage ../servers/etcd/3.5 { };
  ejabberd = callPackage ../servers/xmpp/ejabberd { erlang = erlang_24; };
  ejabberd = callPackage ../servers/xmpp/ejabberd { };
  exhaustive = callPackage ../development/tools/exhaustive { };