Commit 89ea599a authored by Chuang Zhu's avatar Chuang Zhu
Browse files

ejabberd: 23.10 -> 24.02

parent ad0b5eed
Loading
Loading
Loading
Loading
+82 −64
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
@@ -15,13 +20,76 @@

let
  ctlpath = lib.makeBinPath [ bash gnused gnugrep gawk coreutils util-linux procps ];

  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=";
    };
    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 = [ ];
  };

  beamDeps = 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 ];
      };
      ezlib = prev.ezlib.override {
        buildInputs = [ zlib ];
        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 ];
      };
    };
  };

in stdenv.mkDerivation rec {
  pname = "ejabberd";
  version = "23.10";
  version = "24.02";

  nativeBuildInputs = [ makeWrapper autoreconfHook ];
  nativeBuildInputs = [
    makeWrapper
    autoreconfHook
    (rebar3WithPlugins { plugins = [ provider_asn1 rebar3_hex ]; })
  ];

  buildInputs = [ erlang openssl expat libyaml gd ]
  buildInputs = [ erlang ]
    ++ builtins.attrValues beamDeps
    ++ lib.optional withSqlite sqlite
    ++ lib.optional withPam pam
    ++ lib.optional withZlib zlib
@@ -29,63 +97,14 @@ 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=";
    # remember to update the deps FOD hash & its pinned ejabberd-po commit
    hash = "sha256-ttSNO/K+82jpMh41Q2OByG14REuQQmScbEqrAIk5XAc=";
    # remember to update rebar-deps.nix
  };

  passthru.tests = {
    inherit (nixosTests) ejabberd;
  };

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

    inherit src version;

    # 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"}}'
    '';

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

    nativeBuildInputs = [
      git erlang openssl expat libyaml sqlite pam zlib autoreconfHook
    ];

    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
    '';

    dontPatchELF = true;
    dontStrip = true;
    # avoid /nix/store references in the source
    dontPatchShebangs = true;

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

  configureFlags = [
    (lib.enableFeature withMysql "mysql")
    (lib.enableFeature withPgsql "pgsql")
@@ -99,21 +118,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 +140,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 ];
  };
}
+208 −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.4.1";
      src = fetchHex {
        pkg = "unicode_util_compat";
        version = "0.4.1";
        sha256 = "sha256-HRhIxASHzbCzDo7ZdeNOAlhgwC5BnLYV0lWEnzQnQ50=";
      };
      beamDeps = [ ];
    };
    ezlib = builder {
      name = "ezlib";
      version = "1.0.12";
      src = fetchHex {
        pkg = "ezlib";
        version = "1.0.12";
        sha256 = "sha256-MOlDVftCJgqrbhJYLLDFa/IzUV5lXIrq9Idg51YeTrs=";
      };
      beamDeps = [ p1_utils ];
    };
    yconf = builder {
      name = "yconf";
      version = "1.0.15";
      src = fetchHex {
        pkg = "yconf";
        version = "1.0.15";
        sha256 = "sha256-f/KrJNPJgzhCcWuaqqAaj5ZkGnaVy7cBsDRFxN7wERc=";
      };
      beamDeps = [ fast_yaml ];
    };
    xmpp = builder {
      name = "xmpp";
      version = "1.8.1";
      src = fetchHex {
        pkg = "xmpp";
        version = "1.8.1";
        sha256 = "sha256-MtSjCKZhPk5BVfpOguzNyIMwltD6jZnI1CjIAGEeWdM=";
      };
      beamDeps = [ ezlib fast_tls fast_xml idna p1_utils stringprep ];
    };
    stun = builder {
      name = "stun";
      version = "1.2.12";
      src = fetchHex {
        pkg = "stun";
        version = "1.2.12";
        sha256 = "sha256-ogVQMrbTONBFQUIAS8sS+vsMZKsfJz8dDGkj67yO3kA=";
      };
      beamDeps = [ fast_tls p1_utils ];
    };
    stringprep = builder {
      name = "stringprep";
      version = "1.0.29";
      src = fetchHex {
        pkg = "stringprep";
        version = "1.0.29";
        sha256 = "sha256-ko66MEwwBusVEhEOvXuH2xY7AIWaCTdaHkRmFSxsRio=";
      };
      beamDeps = [ p1_utils ];
    };
    pkix = builder {
      name = "pkix";
      version = "1.0.9";
      src = fetchHex {
        pkg = "pkix";
        version = "1.0.9";
        sha256 = "sha256-2qssCc3U7aBcm0WlwA6ZShpfJ2NJKeE3fi5ZtwcQPjo=";
      };
      beamDeps = [ ];
    };
    p1_utils = builder {
      name = "p1_utils";
      version = "1.0.25";
      src = fetchHex {
        pkg = "p1_utils";
        version = "1.0.25";
        sha256 = "sha256-khkhRCjyxuXTGH/465qHg2lcJCdCC+miWYQOB62jKEc=";
      };
      beamDeps = [ ];
    };
    p1_oauth2 = builder {
      name = "p1_oauth2";
      version = "0.6.14";
      src = fetchHex {
        pkg = "p1_oauth2";
        version = "0.6.14";
        sha256 = "sha256-H9OsR05Dci2dWofG34029pjth697uBy7tmNhRR2Zro8=";
      };
      beamDeps = [ ];
    };
    p1_acme = builder {
      name = "p1_acme";
      version = "1.0.22";
      src = fetchHex {
        pkg = "p1_acme";
        version = "1.0.22";
        sha256 = "sha256-wrJaeylaQ12sTyeKc9hBf/KwAgxF4Wg1BOhpLvA+IFc=";
      };
      beamDeps = [ base64url idna jiffy jose yconf ];
    };
    mqtree = builder {
      name = "mqtree";
      version = "1.0.16";
      src = fetchHex {
        pkg = "mqtree";
        version = "1.0.16";
        sha256 = "sha256-yH0clVddtlrym3lcnao77UP1wb+EByp0RpZZvPU1lOs=";
      };
      beamDeps = [ p1_utils ];
    };
    jose = builder {
      name = "jose";
      version = "1.11.5";
      src = fetchHex {
        pkg = "jose";
        version = "1.11.5";
        sha256 = "sha256-3NOyFbr+Aup8WyPa/T64Bipc2PLZBP2cqjI9NwNKs4Q=";
      };
      beamDeps = [ ];
    };
    jiffy = builder {
      name = "jiffy";
      version = "1.1.1";
      src = fetchHex {
        pkg = "jiffy";
        version = "1.1.1";
        sha256 = "sha256-YuHwWBw8GcM6clx4HfqIQQ2L/xu6/DiFolUihrR4XEw=";
      };
      beamDeps = [ ];
    };
    idna = builder {
      name = "idna";
      version = "6.0.0";
      src = fetchHex {
        pkg = "idna";
        version = "6.0.0";
        sha256 = "sha256-S90wXrZOGLAnOGSSBpXLGNeiAh8xoRucX7zZolP5NuI=";
      };
      beamDeps = [ unicode_util_compat ];
    };
    fast_yaml = builder {
      name = "fast_yaml";
      version = "1.0.36";
      src = fetchHex {
        pkg = "fast_yaml";
        version = "1.0.36";
        sha256 = "sha256-Gr6PdY/CqGsI7f+Au8aHz9QevBQSz+wO9KCs/NAyBS8=";
      };
      beamDeps = [ p1_utils ];
    };
    fast_xml = builder {
      name = "fast_xml";
      version = "1.1.51";
      src = fetchHex {
        pkg = "fast_xml";
        version = "1.1.51";
        sha256 = "sha256-f85Bt9GkukOKLXoIjavnSjygc58a8qvLd+Ytr0PgQJo=";
      };
      beamDeps = [ p1_utils ];
    };
    fast_tls = builder {
      name = "fast_tls";
      version = "1.1.19";
      src = fetchHex {
        pkg = "fast_tls";
        version = "1.1.19";
        sha256 = "sha256-2zQyLIeC1MUTnMuAcJ2OyMOAibRCYu3QwvZgrElb04k=";
      };
      beamDeps = [ p1_utils ];
    };
    eimp = builder {
      name = "eimp";
      version = "1.0.22";
      src = fetchHex {
        pkg = "eimp";
        version = "1.0.22";
        sha256 = "sha256-s7n/sdml9KK6iKxBioGRZJMtmp06L8PTLKM4zoVcQ5I=";
      };
      beamDeps = [ p1_utils ];
    };
    cache_tab = builder {
      name = "cache_tab";
      version = "1.0.30";
      src = fetchHex {
        pkg = "cache_tab";
        version = "1.0.30";
        sha256 = "sha256-bYpeANj4TEJidwam2+2wLjTVhJXz7WGTXIR1ygUxzaA=";
      };
      beamDeps = [ p1_utils ];
    };
    base64url = builder {
      name = "base64url";
      version = "1.0.1";
      src = fetchHex {
        pkg = "base64url";
        version = "1.0.1";
        sha256 = "sha256-+bOt1HMaAqmwQQOYtHWzPnVmppU2Ujemve4btEdxn1w=";
      };
      beamDeps = [ ];
    };
  };
in self
+1 −1
Original line number Diff line number Diff line
@@ -25330,7 +25330,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 { };