about summary refs log tree commit diff
path: root/nixpkgs/pkgs/servers/mail/mailman
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/servers/mail/mailman')
-rw-r--r--nixpkgs/pkgs/servers/mail/mailman/default.nix35
-rw-r--r--nixpkgs/pkgs/servers/mail/mailman/hyperkitty.nix71
-rw-r--r--nixpkgs/pkgs/servers/mail/mailman/log-stderr.patch13
-rw-r--r--nixpkgs/pkgs/servers/mail/mailman/mailman-hyperkitty.nix51
-rw-r--r--nixpkgs/pkgs/servers/mail/mailman/package.nix87
-rw-r--r--nixpkgs/pkgs/servers/mail/mailman/postorius.nix28
-rw-r--r--nixpkgs/pkgs/servers/mail/mailman/python.nix34
-rw-r--r--nixpkgs/pkgs/servers/mail/mailman/web.nix51
8 files changed, 370 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/servers/mail/mailman/default.nix b/nixpkgs/pkgs/servers/mail/mailman/default.nix
new file mode 100644
index 000000000000..5571a5bef7f3
--- /dev/null
+++ b/nixpkgs/pkgs/servers/mail/mailman/default.nix
@@ -0,0 +1,35 @@
+{ newScope, lib, python3 }:
+
+let
+  self = lib.makeExtensible (self: let inherit (self) callPackage; in {
+    callPackage = newScope self;
+
+    python3 = callPackage ./python.nix { inherit python3; };
+
+    hyperkitty = callPackage ./hyperkitty.nix { };
+
+    mailman = callPackage ./package.nix { };
+
+    mailman-hyperkitty = callPackage ./mailman-hyperkitty.nix { };
+
+    postorius = callPackage ./postorius.nix { };
+
+    web = callPackage ./web.nix { };
+
+    buildEnvs = { web ? self.web
+                , mailman ? self.mailman
+                , mailman-hyperkitty ? self.mailman-hyperkitty
+                , withHyperkitty ? false
+                , withLDAP ? false
+                }:
+      {
+        mailmanEnv = self.python3.withPackages
+          (ps: [ mailman ps.psycopg2 ]
+            ++ lib.optional withHyperkitty mailman-hyperkitty
+            ++ lib.optionals withLDAP [ ps.python-ldap ps.django-auth-ldap ]);
+        webEnv = self.python3.withPackages
+          (ps: [ web ps.psycopg2 ] ++ lib.optionals withLDAP [ ps.python-ldap ps.django-auth-ldap ]);
+      };
+  });
+
+in self
diff --git a/nixpkgs/pkgs/servers/mail/mailman/hyperkitty.nix b/nixpkgs/pkgs/servers/mail/mailman/hyperkitty.nix
new file mode 100644
index 000000000000..344970ebb564
--- /dev/null
+++ b/nixpkgs/pkgs/servers/mail/mailman/hyperkitty.nix
@@ -0,0 +1,71 @@
+{ lib
+, python3
+, fetchurl
+, nixosTests
+}:
+
+with python3.pkgs;
+
+buildPythonPackage rec {
+  pname = "HyperKitty";
+  version = "1.3.9";
+  pyproject = true;
+
+  disabled = pythonOlder "3.10";
+
+  src = fetchurl {
+    url = "https://gitlab.com/mailman/hyperkitty/-/releases/${version}/downloads/hyperkitty-${version}.tar.gz";
+    hash = "sha256-BfhCh4zZcfwoIfubW/+MUWXwh1yFOH/jpRdQdsj6lME=";
+  };
+
+  nativeBuildInputs = [
+    pdm-backend
+  ];
+
+  propagatedBuildInputs = [
+    django
+    django-gravatar2
+    django-haystack
+    django-mailman3
+    django-q
+    django-compressor
+    django-extensions
+    djangorestframework
+    flufl-lock
+    mistune
+    networkx
+    psycopg2
+    python-dateutil
+    robot-detection
+  ];
+
+  # Some of these are optional runtime dependencies that are not
+  # listed as dependencies in pyproject.toml.  To use these, they
+  # should be dependencies of the Django Python environment, but not
+  # of HyperKitty so they're not included for people who don't need
+  # them.
+  nativeCheckInputs = [
+    beautifulsoup4
+    elastic-transport
+    elasticsearch
+    mock
+    whoosh
+  ] ++ beautifulsoup4.optional-dependencies.lxml;
+
+  checkPhase = ''
+    cd $NIX_BUILD_TOP/$sourceRoot
+    PYTHONPATH=.:$PYTHONPATH python example_project/manage.py test \
+      --settings=hyperkitty.tests.settings_test hyperkitty
+  '';
+
+  passthru.tests = { inherit (nixosTests) mailman; };
+
+  meta = {
+    changelog = "https://docs.mailman3.org/projects/hyperkitty/en/latest/news.html";
+    homepage = "https://www.gnu.org/software/mailman/";
+    description = "Archiver for GNU Mailman v3";
+    license = lib.licenses.gpl3;
+    platforms = lib.platforms.linux;
+    maintainers = with lib.maintainers; [ qyliss ];
+  };
+}
diff --git a/nixpkgs/pkgs/servers/mail/mailman/log-stderr.patch b/nixpkgs/pkgs/servers/mail/mailman/log-stderr.patch
new file mode 100644
index 000000000000..2edbe1f18313
--- /dev/null
+++ b/nixpkgs/pkgs/servers/mail/mailman/log-stderr.patch
@@ -0,0 +1,13 @@
+diff --git a/src/mailman/core/logging.py b/src/mailman/core/logging.py
+index f8f87279f..7ff13b003 100644
+--- a/src/mailman/core/logging.py
++++ b/src/mailman/core/logging.py
+@@ -142,6 +142,8 @@ def _init_logger(propagate, sub_name, log, logger_config):
+         address, facility = _get_syslog_params(logger_config)
+         handler = logging.handlers.SysLogHandler(
+             address=address, facility=facility)
++    elif logger_config.handler == 'stderr':
++        handler = logging.StreamHandler(sys.stderr)
+     else:
+         path_str = logger_config.path
+         path_abs = os.path.normpath(os.path.join(config.LOG_DIR, path_str))
diff --git a/nixpkgs/pkgs/servers/mail/mailman/mailman-hyperkitty.nix b/nixpkgs/pkgs/servers/mail/mailman/mailman-hyperkitty.nix
new file mode 100644
index 000000000000..dfec900b0214
--- /dev/null
+++ b/nixpkgs/pkgs/servers/mail/mailman/mailman-hyperkitty.nix
@@ -0,0 +1,51 @@
+{ lib
+, python3
+, fetchPypi
+, mailman
+, nixosTests
+}:
+
+with python3.pkgs;
+buildPythonPackage rec {
+  pname = "mailman-hyperkitty";
+  version = "1.2.1";
+  format = "setuptools";
+
+  disabled = pythonOlder "3.9";
+
+  src = fetchPypi {
+    inherit pname version;
+    sha256 = "sha256-+Nad+8bMtYKJbUCpppRXqhB1zdbvvFXTTHlwJLQLzDg=";
+  };
+
+  propagatedBuildInputs = [
+    mailman
+    requests
+    zope-interface
+  ];
+
+  nativeCheckInputs = [
+    mock
+    nose2
+  ];
+
+  checkPhase = ''
+    ${python.interpreter} -m nose2 -v
+  '';
+
+  # There is an AssertionError
+  doCheck = false;
+
+  pythonImportsCheck = [
+    "mailman_hyperkitty"
+  ];
+
+  passthru.tests = { inherit (nixosTests) mailman; };
+
+  meta = with lib; {
+    description = "Mailman archiver plugin for HyperKitty";
+    homepage = "https://gitlab.com/mailman/mailman-hyperkitty";
+    license = licenses.gpl3Plus;
+    maintainers = with maintainers; [ qyliss ];
+  };
+}
diff --git a/nixpkgs/pkgs/servers/mail/mailman/package.nix b/nixpkgs/pkgs/servers/mail/mailman/package.nix
new file mode 100644
index 000000000000..190d9c757f60
--- /dev/null
+++ b/nixpkgs/pkgs/servers/mail/mailman/package.nix
@@ -0,0 +1,87 @@
+{ lib
+, fetchpatch
+, python3
+, fetchPypi
+, postfix
+, lynx
+, nixosTests
+}:
+
+with python3.pkgs;
+
+buildPythonPackage rec {
+  pname = "mailman";
+  version = "3.3.9";
+  disabled = pythonOlder "3.6";
+
+  src = fetchPypi {
+    inherit pname version;
+    hash = "sha256-GblXI6IwkLl+V1gEbMAe1baVyZOHMaYaYITXcTkp2Mo=";
+  };
+
+  propagatedBuildInputs = with python3.pkgs; [
+    aiosmtpd
+    alembic
+    authheaders
+    click
+    dnspython
+    falcon
+    flufl-bounce
+    flufl-i18n
+    flufl-lock
+    gunicorn
+    lazr-config
+    passlib
+    python-dateutil
+    requests
+    sqlalchemy
+    zope-component
+    zope-configuration
+  ];
+
+  checkInputs = [
+    sphinx
+  ];
+
+  patches = [
+    # https://gitlab.com/mailman/mailman/-/merge_requests/594
+    (fetchpatch {
+      url = "https://gitlab.com/qyliss/mailman/-/commit/4012396aa41d9f6c03fda89a13cc7bc655c19dd8.patch";
+      sha256 = "126nmqi7jma399lsf7gym5kra3xbl4mcs67hzfgn497vvzx77q47";
+    })
+    (fetchpatch {
+      url = "https://gitlab.com/mailman/mailman/-/commit/4b206e2a5267a0e17f345fd7b2d957122ba57566.patch";
+      sha256 = "06axmrn74p81wvcki36c7gfj5fp5q15zxz2yl3lrvijic7hbs4n2";
+    })
+    (fetchpatch {
+      url = "https://gitlab.com/mailman/mailman/-/commit/9613154f3c04fa2383fbf017031ef263c291418d.patch";
+      sha256 = "0vyw87s857vfxbf7kihwb6w094xyxmxbi1bpdqi3ybjamjycp55r";
+    })
+    ./log-stderr.patch
+  ];
+
+  postPatch = ''
+    substituteInPlace src/mailman/config/postfix.cfg \
+      --replace /usr/sbin/postmap ${postfix}/bin/postmap
+    substituteInPlace src/mailman/config/schema.cfg \
+      --replace /usr/bin/lynx ${lynx}/bin/lynx
+  '';
+
+  # Mailman assumes that those scripts in $out/bin are Python scripts. Wrapping
+  # them in shell code breaks this assumption. Use the wrapped version (see
+  # wrapped.nix) if you need the CLI (rather than the Python library).
+  #
+  # This gives a properly wrapped 'mailman' command plus an interpreter that
+  # has all the necessary search paths to execute unwrapped 'master' and
+  # 'runner' scripts.
+  dontWrapPythonPrograms = true;
+
+  passthru.tests = { inherit (nixosTests) mailman; };
+
+  meta = {
+    homepage = "https://www.gnu.org/software/mailman/";
+    description = "Free software for managing electronic mail discussion and newsletter lists";
+    license = lib.licenses.gpl3Plus;
+    maintainers = with lib.maintainers; [ qyliss ];
+  };
+}
diff --git a/nixpkgs/pkgs/servers/mail/mailman/postorius.nix b/nixpkgs/pkgs/servers/mail/mailman/postorius.nix
new file mode 100644
index 000000000000..1f3171f18a7f
--- /dev/null
+++ b/nixpkgs/pkgs/servers/mail/mailman/postorius.nix
@@ -0,0 +1,28 @@
+{ lib, python3, fetchPypi, nixosTests }:
+
+with python3.pkgs;
+
+buildPythonPackage rec {
+  pname = "postorius";
+  version = "1.3.10";
+
+  src = fetchPypi {
+    inherit pname version;
+    hash = "sha256-GmbIqO+03LgbUxJ1nTStXrYN3t2MfvzbeYRAipfTW1o=";
+  };
+
+  propagatedBuildInputs = [ django-mailman3 readme-renderer ];
+  nativeCheckInputs = [ beautifulsoup4 vcrpy mock ];
+
+  # Tries to connect to database.
+  doCheck = false;
+
+  passthru.tests = { inherit (nixosTests) mailman; };
+
+  meta = with lib; {
+    homepage = "https://docs.mailman3.org/projects/postorius";
+    description = "Web-based user interface for managing GNU Mailman";
+    license = licenses.gpl3Plus;
+    maintainers = with maintainers; [ qyliss ];
+  };
+}
diff --git a/nixpkgs/pkgs/servers/mail/mailman/python.nix b/nixpkgs/pkgs/servers/mail/mailman/python.nix
new file mode 100644
index 000000000000..29d2f6c6d36a
--- /dev/null
+++ b/nixpkgs/pkgs/servers/mail/mailman/python.nix
@@ -0,0 +1,34 @@
+{ python3, fetchPypi, lib, overlay ? (_: _: {}) }:
+
+python3.override {
+  packageOverrides = lib.composeExtensions
+    (self: super: {
+      /*
+        This overlay can be used whenever we need to override
+        dependencies specific to the mailman ecosystem: in the past
+        this was necessary for e.g. psycopg2[1] or sqlalchemy[2].
+
+        In such a large ecosystem this sort of issue is expected
+        to arise again. Since we don't want to clutter the python package-set
+        itself with version overrides and don't want to change the APIs
+        in here back and forth every time this comes up (and as a result
+        force users to change their code accordingly), this overlay
+        is kept on purpose, even when empty.
+
+        [1] 72a14ea563a3f5bf85db659349a533fe75a8b0ce
+        [2] f931bc81d63f5cfda55ac73d754c87b3fd63b291
+      */
+
+      # django-q tests fail with redis 5.0.0.
+      # https://gitlab.com/mailman/hyperkitty/-/issues/493
+      redis = super.redis.overridePythonAttrs ({ pname, ... }: rec {
+        version = "4.6.0";
+        src = fetchPypi {
+          inherit pname version;
+          hash = "sha256-WF3FFrnrBCphnvCjnD19Vf6BvbTfCaUsnN3g0Hvxqn0=";
+        };
+      });
+    })
+
+    overlay;
+}
diff --git a/nixpkgs/pkgs/servers/mail/mailman/web.nix b/nixpkgs/pkgs/servers/mail/mailman/web.nix
new file mode 100644
index 000000000000..dc5ef230c235
--- /dev/null
+++ b/nixpkgs/pkgs/servers/mail/mailman/web.nix
@@ -0,0 +1,51 @@
+{ lib, python3, fetchPypi
+, sassc, hyperkitty, postorius
+, nixosTests
+}:
+
+with python3.pkgs;
+
+buildPythonPackage rec {
+  pname = "mailman-web";
+  version = "0.0.8";
+  disabled = pythonOlder "3.8";
+
+  src = fetchPypi {
+    inherit pname version;
+    hash = "sha256-nN/L+X2Rvm6rqkscns4Tn2TAr59O5lCJObvcJp6M0+Q=";
+  };
+
+  postPatch = ''
+    # Django is depended on transitively by hyperkitty and postorius,
+    # and mailman_web has overly restrictive version bounds on it, so
+    # let's remove it.
+    sed -i '/^[[:space:]]*django/Id' setup.cfg
+
+    # Upstream seems to mostly target installing on top of existing
+    # distributions, and uses a path appropriate for that, but we are
+    # a distribution, so use a state directory appropriate for a
+    # distro package.
+    substituteInPlace mailman_web/settings/base.py \
+        --replace /opt/mailman/web /var/lib/mailman-web
+  '';
+
+  nativeBuildInputs = [ setuptools-scm ];
+  propagatedBuildInputs = [ hyperkitty postorius whoosh ];
+
+  # Tries to check runtime configuration.
+  doCheck = false;
+
+  makeWrapperArgs = [
+    "--suffix PATH : ${lib.makeBinPath [ sassc ]}"
+  ];
+
+  passthru.tests = { inherit (nixosTests) mailman; };
+
+  meta = with lib; {
+    homepage = "https://gitlab.com/mailman/mailman-web";
+    description = "Django project for Mailman 3 web interface";
+    mainProgram = "mailman-web";
+    license = licenses.gpl3Plus;
+    maintainers = with maintainers; [ qyliss m1cr0man ];
+  };
+}