git.iko.soy/typeable/nixpkgs
on master help sign in
mailman-web: use upstream, improve NixOS module

Previously, some files were copied into the Nixpkgs tree, which meant we wouldn't easily be able to update them, and was also just messy. The reason it was done that way before was so that a few NixOS options could be substituted in. Some problems with doing it this way were that the _package_ changed depending on the values of the settings, which is pretty strange, and also that it only allowed those few settings to be set. In the new model, mailman-web is a usable package without needing to override, and I've implemented the NixOS options in a much more flexible way. NixOS' mailman-web config file first reads the mailman-web settings to use as defaults, but then it loads another configuration file generated from the new services.mailman.webSettings option, so _any_ mailman-web Django setting can be customised by the user, rather than just the three that were supported before. I've kept the old options, but there might not really be any good reason to keep them.

commit881dd9963ffe81396ffdc9748182a1423ac86018 authorAlyssa Ross <hi@alyssa.is> dateThu 9 Jan 2020, 21:35 (7 years ago) parenta8538a7
6 files changed+111−637
nixos/modules/services/mail/mailman.nix+78−48 pkgs/servers/mail/mailman/settings.py−508 pkgs/servers/mail/mailman/urls.py−34 pkgs/servers/mail/mailman/web.nix+31−30 pkgs/servers/mail/mailman/wsgi.py−17 pkgs/top-level/all-packages.nix+2
nixos/modules/services/mail/mailman.nix+78−48
@@ -6,24 +6,18 @@ let
66
77 cfg = config.services.mailman;
88
9− mailmanWeb = pkgs.python3Packages.mailman-web.override {
10− serverEMail = cfg.siteOwner;
11− archiverKey = cfg.hyperkittyApiKey;
12− allowedHosts = cfg.webHosts;
13− };
14−
15− mailmanWebPyEnv = pkgs.python3.withPackages (x: with x; [mailman-web]);
16−
17− mailmanWebExe = with pkgs; stdenv.mkDerivation {
18− inherit (mailmanWeb) name;
19− buildInputs = [makeWrapper];
20− unpackPhase = ":";
21− installPhase = ''
22− mkdir -p $out/bin
23− makeWrapper ${mailmanWebPyEnv}/bin/django-admin $out/bin/mailman-web \
24− --set DJANGO_SETTINGS_MODULE settings
25− '';
26− };
9+ # This deliberately doesn't use recursiveUpdate so users can
10+ # override the defaults.
11+ settings = {
12+ DEFAULT_FROM_EMAIL = cfg.siteOwner;
13+ SERVER_EMAIL = cfg.siteOwner;
14+ ALLOWED_HOSTS = [ "localhost" "127.0.0.1" ] ++ cfg.webHosts;
15+ COMPRESS_OFFLINE = true;
16+ STATIC_ROOT = "/var/lib/mailman-web/static";
17+ MEDIA_ROOT = "/var/lib/mailman-web/media";
18+ } // cfg.webSettings;
19+
20+ settingsJSON = pkgs.writeText "settings.json" (builtins.toJSON settings);
2721
2822 mailmanCfg = ''
2923 [mailman]
@@ -98,8 +92,8 @@ in {
9892
9993 webRoot = mkOption {
10094 type = types.path;
101− default = "${mailmanWeb}/${pkgs.python3.sitePackages}";
102− defaultText = "pkgs.python3Packages.mailman-web";
95+ default = "${pkgs.mailman-web}/${pkgs.python3.sitePackages}";
96+ defaultText = "\${pkgs.mailman-web}/\${pkgs.python3.sitePackages}";
10397 description = ''
10498 The web root for the Hyperkity + Postorius apps provided by Mailman.
10599 This variable can be set, of course, but it mainly exists so that site
@@ -128,6 +122,14 @@ in {
128122 '';
129123 };
130124
125+ webSettings = mkOption {
126+ type = types.attrs;
127+ default = {};
128+ description = ''
129+ Overrides for the default mailman-web Django settings.
130+ '';
131+ };
132+
131133 hyperkitty = {
132134 enable = mkEnableOption "the Hyperkitty archiver for Mailman";
133135
@@ -175,10 +177,27 @@ in {
175177
176178 users.users.mailman = { description = "GNU Mailman"; isSystemUser = true; };
177179
178− environment = {
179− systemPackages = [ pkgs.mailman mailmanWebExe pkgs.sassc ];
180− etc."mailman.cfg".text = mailmanCfg;
181− };
180+ environment.etc."mailman.cfg".text = mailmanCfg;
181+
182+ environment.etc."mailman3/settings.py".text = ''
183+ import os
184+
185+ # Required by mailman_web.settings, but will be overridden when
186+ # settings_local.json is loaded.
187+ os.environ["SECRET_KEY"] = ""
188+
189+ from mailman_web.settings import *
190+
191+ import json
192+
193+ with open('${settingsJSON}') as f:
194+ globals().update(json.load(f))
195+
196+ with open('/var/lib/mailman-web/settings_local.json') as f:
197+ globals().update(json.load(f))
198+ '';
199+
200+ environment.systemPackages = [ cfg.package ] ++ (with pkgs; [ mailman-web ]);
182201
183202 services.postfix = {
184203 recipientDelimiter = "+"; # bake recipient addresses in mail envelopes via VERP
@@ -201,36 +220,39 @@ in {
201220 };
202221 };
203222
204− systemd.services.mailman-secrets = {
205− description = "Generate Hyperkitty API key";
223+ systemd.services.mailman-settings = {
224+ description = "Generate settings files (including secrets) for Mailman";
206225 before = [ "mailman.service" "mailman-web.service" "hyperkitty.service" "httpd.service" "uwsgi.service" ];
207226 requiredBy = [ "mailman.service" "mailman-web.service" "hyperkitty.service" "httpd.service" "uwsgi.service" ];
227+ path = with pkgs; [ jq ];
208228 script = ''
209229 mailmanDir=/var/lib/mailman
210230 mailmanWebDir=/var/lib/mailman-web
211231
212232 mailmanCfg=$mailmanDir/mailman-hyperkitty.cfg
213− hyperkittyCfg=$mailmanWebDir/settings_local.py
214−
215− [ -e $mailmanCfg -o -e $hyperkittyCfg ] && exit 0
233+ mailmanWebCfg=$mailmanWebDir/settings_local.json
216234
217235 install -m 0700 -o mailman -g nogroup -d $mailmanDir
218236 install -m 0700 -o ${cfg.webUser} -g nogroup -d $mailmanWebDir
219237
220− hyperkittyApiKey=$(tr -dc A-Za-z0-9 < /dev/urandom | head -c 64)
221− secretKey=$(tr -dc A-Za-z0-9 < /dev/urandom | head -c 64)
238+ if [ ! -e $mailmanWebCfg ]; then
239+ hyperkittyApiKey=$(tr -dc A-Za-z0-9 < /dev/urandom | head -c 64)
240+ secretKey=$(tr -dc A-Za-z0-9 < /dev/urandom | head -c 64)
222241
223− hyperkittyCfgTmp=$(mktemp)
224− echo "MAILMAN_ARCHIVER_KEY='$hyperkittyApiKey'" >>"$hyperkittyCfgTmp"
225− echo "SECRET_KEY='$secretKey'" >>"$hyperkittyCfgTmp"
226− chown ${cfg.webUser} "$hyperkittyCfgTmp"
242+ mailmanWebCfgTmp=$(mktemp)
243+ jq -n '.MAILMAN_ARCHIVER_KEY=$archiver_key | .SECRET_KEY=$secret_key' \
244+ --arg archiver_key "$hyperkittyApiKey" \
245+ --arg secret_key "$secretKey" \
246+ >"$mailmanWebCfgTmp"
247+ chown ${cfg.webUser} "$mailmanWebCfgTmp"
248+ mv -n "$mailmanWebCfgTmp" $mailmanWebCfg
249+ fi
227250
251+ hyperkittyApiKey="$(jq -r .MAILMAN_ARCHIVER_KEY $mailmanWebCfg)"
228252 mailmanCfgTmp=$(mktemp)
229253 sed "s/@API_KEY@/$hyperkittyApiKey/g" ${mailmanHyperkittyCfg} >"$mailmanCfgTmp"
230254 chown mailman "$mailmanCfgTmp"
231−
232− mv -n "$hyperkittyCfgTmp" $hyperkittyCfg
233− mv -n "$mailmanCfgTmp" $mailmanCfg
255+ mv "$mailmanCfgTmp" $mailmanCfg
234256 '';
235257 serviceConfig = {
236258 Type = "oneshot";
@@ -241,11 +263,12 @@ in {
241263 description = "Init Postorius DB";
242264 before = [ "httpd.service" "uwsgi.service" ];
243265 requiredBy = [ "httpd.service" "uwsgi.service" ];
266+ restartTriggers = [ config.environment.etc."mailman3/settings.py".source ];
244267 script = ''
245− ${mailmanWebExe}/bin/mailman-web migrate
268+ ${pkgs.mailman-web}/bin/mailman-web migrate
246269 rm -rf static
247− ${mailmanWebExe}/bin/mailman-web collectstatic
248− ${mailmanWebExe}/bin/mailman-web compress
270+ ${pkgs.mailman-web}/bin/mailman-web collectstatic
271+ ${pkgs.mailman-web}/bin/mailman-web compress
249272 '';
250273 serviceConfig = {
251274 User = cfg.webUser;
@@ -267,9 +290,10 @@ in {
267290 inherit (cfg.hyperkitty) enable;
268291 description = "GNU Hyperkitty QCluster Process";
269292 after = [ "network.target" ];
293+ restartTriggers = [ config.environment.etc."mailman3/settings.py".source ];
270294 wantedBy = [ "mailman.service" "multi-user.target" ];
271295 serviceConfig = {
272− ExecStart = "${mailmanWebExe}/bin/mailman-web qcluster";
296+ ExecStart = "${pkgs.mailman-web}/bin/mailman-web qcluster";
273297 User = cfg.webUser;
274298 WorkingDirectory = "/var/lib/mailman-web";
275299 };
@@ -279,8 +303,9 @@ in {
279303 inherit (cfg.hyperkitty) enable;
280304 description = "Trigger minutely Hyperkitty events";
281305 startAt = "minutely";
306+ restartTriggers = [ config.environment.etc."mailman3/settings.py".source ];
282307 serviceConfig = {
283− ExecStart = "${mailmanWebExe}/bin/mailman-web runjobs minutely";
308+ ExecStart = "${pkgs.mailman-web}/bin/mailman-web runjobs minutely";
284309 User = cfg.webUser;
285310 WorkingDirectory = "/var/lib/mailman-web";
286311 };
@@ -290,8 +315,9 @@ in {
290315 inherit (cfg.hyperkitty) enable;
291316 description = "Trigger quarter-hourly Hyperkitty events";
292317 startAt = "*:00/15";
318+ restartTriggers = [ config.environment.etc."mailman3/settings.py".source ];
293319 serviceConfig = {
294− ExecStart = "${mailmanWebExe}/bin/mailman-web runjobs quarter_hourly";
320+ ExecStart = "${pkgs.mailman-web}/bin/mailman-web runjobs quarter_hourly";
295321 User = cfg.webUser;
296322 WorkingDirectory = "/var/lib/mailman-web";
297323 };
@@ -301,8 +327,9 @@ in {
301327 inherit (cfg.hyperkitty) enable;
302328 description = "Trigger hourly Hyperkitty events";
303329 startAt = "hourly";
330+ restartTriggers = [ config.environment.etc."mailman3/settings.py".source ];
304331 serviceConfig = {
305− ExecStart = "${mailmanWebExe}/bin/mailman-web runjobs hourly";
332+ ExecStart = "${pkgs.mailman-web}/bin/mailman-web runjobs hourly";
306333 User = cfg.webUser;
307334 WorkingDirectory = "/var/lib/mailman-web";
308335 };
@@ -312,8 +339,9 @@ in {
312339 inherit (cfg.hyperkitty) enable;
313340 description = "Trigger daily Hyperkitty events";
314341 startAt = "daily";
342+ restartTriggers = [ config.environment.etc."mailman3/settings.py".source ];
315343 serviceConfig = {
316− ExecStart = "${mailmanWebExe}/bin/mailman-web runjobs daily";
344+ ExecStart = "${pkgs.mailman-web}/bin/mailman-web runjobs daily";
317345 User = cfg.webUser;
318346 WorkingDirectory = "/var/lib/mailman-web";
319347 };
@@ -323,8 +351,9 @@ in {
323351 inherit (cfg.hyperkitty) enable;
324352 description = "Trigger weekly Hyperkitty events";
325353 startAt = "weekly";
354+ restartTriggers = [ config.environment.etc."mailman3/settings.py".source ];
326355 serviceConfig = {
327− ExecStart = "${mailmanWebExe}/bin/mailman-web runjobs weekly";
356+ ExecStart = "${pkgs.mailman-web}/bin/mailman-web runjobs weekly";
328357 User = cfg.webUser;
329358 WorkingDirectory = "/var/lib/mailman-web";
330359 };
@@ -334,8 +363,9 @@ in {
334363 inherit (cfg.hyperkitty) enable;
335364 description = "Trigger yearly Hyperkitty events";
336365 startAt = "yearly";
366+ restartTriggers = [ config.environment.etc."mailman3/settings.py".source ];
337367 serviceConfig = {
338− ExecStart = "${mailmanWebExe}/bin/mailman-web runjobs yearly";
368+ ExecStart = "${pkgs.mailman-web}/bin/mailman-web runjobs yearly";
339369 User = cfg.webUser;
340370 WorkingDirectory = "/var/lib/mailman-web";
341371 };
pkgs/servers/mail/mailman/settings.pydeleted−508
@@ -1,508 +0,0 @@
1−# -*- coding: utf-8 -*-
2−# Copyright (C) 1998-2019 by the Free Software Foundation, Inc.
3−#
4−# This file is part of Postorius.
5−#
6−# Postorius is free software: you can redistribute it and/or modify it under
7−# the terms of the GNU General Public License as published by the Free
8−# Software Foundation, either version 3 of the License, or (at your option)
9−# any later version.
10−#
11−# Postorius is distributed in the hope that it will be useful, but WITHOUT
12−# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13−# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14−# more details.
15−#
16−# You should have received a copy of the GNU General Public License along with
17−# Postorius. If not, see <http://www.gnu.org/licenses/>.
18−
19−"""
20−Django settings for postorius project.
21−
22−For more information on this file, see
23−https://docs.djangoproject.com/en/1.9/topics/settings/
24−
25−For the full list of settings and their values, see
26−https://docs.djangoproject.com/en/1.9/ref/settings/
27−"""
28−
29−# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
30−import os
31−
32−# Compatibility with Bootstrap 3
33−from django.contrib.messages import constants as messages
34−
35−
36−BASE_DIR = os.path.dirname(os.path.abspath(__file__))
37−
38−
39−# Quick-start development settings - unsuitable for production
40−# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/
41−
42−# SECURITY WARNING: don't run with debug turned on in production!
43−DEBUG = False
44−
45−ADMINS = (
46− #('Admin', 'webmaster@example.com'),
47−)
48−
49−SITE_ID = 1
50−
51−# Hosts/domain names that are valid for this site; required if DEBUG is False
52−# See https://docs.djangoproject.com/en/1.8/ref/settings/#allowed-hosts
53−ALLOWED_HOSTS = [
54− "localhost", # Archiving API from Mailman, keep it.
55− "127.0.0.1",
56− # Add here all production URLs you may have.
57− @ALLOWED_HOSTS@
58−]
59−
60−# Mailman API credentials
61−MAILMAN_REST_API_URL = 'http://localhost:8001'
62−MAILMAN_REST_API_USER = 'restadmin'
63−MAILMAN_REST_API_PASS = 'restpass'
64−MAILMAN_ARCHIVER_FROM = ('127.0.0.1', '::1')
65−
66−# Application definition
67−
68−INSTALLED_APPS = (
69− 'hyperkitty',
70− 'postorius',
71− 'django_mailman3',
72− # Uncomment the next line to enable the admin:
73− 'django.contrib.admin',
74− # Uncomment the next line to enable admin documentation:
75− # 'django.contrib.admindocs',
76− 'django.contrib.auth',
77− 'django.contrib.contenttypes',
78− 'django.contrib.sessions',
79− 'django.contrib.sites',
80− 'django.contrib.messages',
81− 'django.contrib.staticfiles',
82− 'rest_framework',
83− 'django_gravatar',
84− 'compressor',
85− 'haystack',
86− 'django_extensions',
87− 'django_q',
88− 'allauth',
89− 'allauth.account',
90− 'allauth.socialaccount',
91− 'django_mailman3.lib.auth.fedora',
92− 'allauth.socialaccount.providers.openid',
93− 'allauth.socialaccount.providers.github',
94− 'allauth.socialaccount.providers.gitlab',
95− 'allauth.socialaccount.providers.google',
96− #'allauth.socialaccount.providers.facebook',
97− #'allauth.socialaccount.providers.twitter',
98− 'allauth.socialaccount.providers.stackexchange',
99−)
100−
101−
102−MIDDLEWARE = (
103− 'django.middleware.security.SecurityMiddleware',
104− 'django.contrib.sessions.middleware.SessionMiddleware',
105− 'django.middleware.common.CommonMiddleware',
106− 'django.middleware.csrf.CsrfViewMiddleware',
107− 'django.contrib.auth.middleware.AuthenticationMiddleware',
108− 'django.contrib.messages.middleware.MessageMiddleware',
109− 'django.middleware.clickjacking.XFrameOptionsMiddleware',
110− 'django_mailman3.middleware.TimezoneMiddleware',
111−)
112−
113−ROOT_URLCONF = 'urls'
114−
115−
116−TEMPLATES = [
117− {
118− 'BACKEND': 'django.template.backends.django.DjangoTemplates',
119− 'DIRS': [],
120− 'APP_DIRS': True,
121− 'OPTIONS': {
122− 'context_processors': [
123− 'django.template.context_processors.debug',
124− 'django.template.context_processors.i18n',
125− 'django.template.context_processors.media',
126− 'django.template.context_processors.static',
127− 'django.template.context_processors.tz',
128− 'django.template.context_processors.csrf',
129− 'django.template.context_processors.request',
130− 'django.contrib.auth.context_processors.auth',
131− 'django.contrib.messages.context_processors.messages',
132− 'django_mailman3.context_processors.common',
133− 'hyperkitty.context_processors.common',
134− ],
135− },
136− },
137−]
138−
139−WSGI_APPLICATION = 'wsgi.application'
140−
141−
142−# Database
143−# https://docs.djangoproject.com/en/1.9/ref/settings/#databases
144−
145−DATABASES = {
146− 'default': {
147− 'ENGINE': 'django.db.backends.sqlite3',
148− 'NAME': '/var/lib/mailman-web/mailman-web.db'
149− }
150−}
151−
152−# Password validation
153−# https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators
154−
155−AUTH_PASSWORD_VALIDATORS = [
156− {
157− 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
158− },
159− {
160− 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
161− },
162− {
163− 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
164− },
165− {
166− 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
167− },
168−]
169−
170−
171−# If you're behind a proxy, use the X-Forwarded-Host header
172−# See https://docs.djangoproject.com/en/1.8/ref/settings/#use-x-forwarded-host
173−# USE_X_FORWARDED_HOST = True
174−
175−# And if your proxy does your SSL encoding for you, set SECURE_PROXY_SSL_HEADER
176−# https://docs.djangoproject.com/en/1.8/ref/settings/#secure-proxy-ssl-header
177−# SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
178−# SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_SCHEME', 'https')
179−
180−# Other security settings
181−# SECURE_SSL_REDIRECT = True
182−# If you set SECURE_SSL_REDIRECT to True, make sure the SECURE_REDIRECT_EXEMPT
183−# contains at least this line:
184−# SECURE_REDIRECT_EXEMPT = [
185−# "archives/api/mailman/.*", # Request from Mailman.
186−# ]
187−# SESSION_COOKIE_SECURE = True
188−# SECURE_CONTENT_TYPE_NOSNIFF = True
189−# SECURE_BROWSER_XSS_FILTER = True
190−# CSRF_COOKIE_SECURE = True
191−# CSRF_COOKIE_HTTPONLY = True
192−# X_FRAME_OPTIONS = 'DENY'
193−
194−
195−# Internationalization
196−# https://docs.djangoproject.com/en/1.9/topics/i18n/
197−
198−LANGUAGE_CODE = 'en-us'
199−
200−TIME_ZONE = 'UTC'
201−
202−USE_I18N = True
203−
204−USE_L10N = True
205−
206−USE_TZ = True
207−
208−
209−# Static files (CSS, JavaScript, Images)
210−# https://docs.djangoproject.com/en/1.9/howto/static-files/
211−
212−
213−# Absolute path to the directory static files should be collected to.
214−# Don't put anything in this directory yourself; store your static files
215−# in apps' "static/" subdirectories and in STATICFILES_DIRS.
216−# Example: "/var/www/example.com/static/"
217−STATIC_ROOT = 'static'
218−
219−# URL prefix for static files.
220−# Example: "http://example.com/static/", "http://static.example.com/"
221−STATIC_URL = '/static/'
222−
223−# Additional locations of static files
224−STATICFILES_DIRS = (
225− # Put strings here, like "/home/html/static" or "C:/www/django/static".
226− # Always use forward slashes, even on Windows.
227− # Don't forget to use absolute paths, not relative paths.
228− # BASE_DIR + '/static/',
229−)
230−
231−# List of finder classes that know how to find static files in
232−# various locations.
233−STATICFILES_FINDERS = (
234− 'django.contrib.staticfiles.finders.FileSystemFinder',
235− 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
236− # 'django.contrib.staticfiles.finders.DefaultStorageFinder',
237− 'compressor.finders.CompressorFinder',
238−)
239−
240−# Django 1.6+ defaults to a JSON serializer, but it won't work with
241−# django-openid, see
242−# https://bugs.launchpad.net/django-openid-auth/+bug/1252826
243−SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'
244−
245−
246−LOGIN_URL = 'account_login'
247−LOGIN_REDIRECT_URL = 'hk_root'
248−LOGOUT_URL = 'account_logout'
249−
250−
251−# If you enable internal authentication, this is the address that the emails
252−# will appear to be coming from. Make sure you set a valid domain name,
253−# otherwise the emails may get rejected.
254−# https://docs.djangoproject.com/en/1.8/ref/settings/#default-from-email
255−DEFAULT_FROM_EMAIL = "@SERVER_EMAIL@"
256−
257−# If you enable email reporting for error messages, this is where those emails
258−# will appear to be coming from. Make sure you set a valid domain name,
259−# otherwise the emails may get rejected.
260−# https://docs.djangoproject.com/en/1.8/ref/settings/#std:setting-SERVER_EMAIL
261−SERVER_EMAIL = "@SERVER_EMAIL@"
262−
263−
264−MESSAGE_TAGS = {
265− messages.ERROR: 'danger'
266−}
267−
268−
269−#
270−# Social auth
271−#
272−AUTHENTICATION_BACKENDS = (
273− 'django.contrib.auth.backends.ModelBackend',
274− 'allauth.account.auth_backends.AuthenticationBackend',
275−)
276−
277−# Django Allauth
278−ACCOUNT_AUTHENTICATION_METHOD = "username_email"
279−ACCOUNT_EMAIL_REQUIRED = True
280−ACCOUNT_EMAIL_VERIFICATION = "mandatory"
281−ACCOUNT_DEFAULT_HTTP_PROTOCOL = "https"
282−ACCOUNT_UNIQUE_EMAIL = True
283−
284−SOCIALACCOUNT_PROVIDERS = {
285− 'openid': {
286− 'SERVERS': [
287− dict(id='yahoo',
288− name='Yahoo',
289− openid_url='http://me.yahoo.com'),
290− ],
291− },
292− 'google': {
293− 'SCOPE': ['profile', 'email'],
294− 'AUTH_PARAMS': {'access_type': 'online'},
295− },
296− 'facebook': {
297− 'METHOD': 'oauth2',
298− 'SCOPE': ['email'],
299− 'FIELDS': [
300− 'email',
301− 'name',
302− 'first_name',
303− 'last_name',
304− 'locale',
305− 'timezone',
306− ],
307− 'VERSION': 'v2.4',
308− },
309− 'gitlab': {
310− 'GITLAB_URL': 'https://gitlab.com',
311− 'SCOPE': ['read_user'],
312− },
313−}
314−
315−
316−#
317−# Gravatar
318−# https://github.com/twaddington/django-gravatar
319−#
320−# Gravatar base url.
321−# GRAVATAR_URL = 'http://cdn.libravatar.org/'
322−# Gravatar base secure https url.
323−# GRAVATAR_SECURE_URL = 'https://seccdn.libravatar.org/'
324−# Gravatar size in pixels.
325−# GRAVATAR_DEFAULT_SIZE = '80'
326−# An image url or one of the following: 'mm', 'identicon', 'monsterid',
327−# 'wavatar', 'retro'.
328−# GRAVATAR_DEFAULT_IMAGE = 'mm'
329−# One of the following: 'g', 'pg', 'r', 'x'.
330−# GRAVATAR_DEFAULT_RATING = 'g'
331−# True to use https by default, False for plain http.
332−# GRAVATAR_DEFAULT_SECURE = True
333−
334−# These can be set to override the defaults but are not mandatory:
335−# EMAIL_CONFIRMATION_TEMPLATE = 'postorius/address_confirmation_message.txt'
336−# EMAIL_CONFIRMATION_SUBJECT = 'Confirmation needed'
337−
338−#
339−# django-compressor
340−# https://pypi.python.org/pypi/django_compressor
341−#
342−COMPRESS_PRECOMPILERS = (
343− ('text/x-scss', '/run/current-system/sw/bin/sassc -t compressed {infile} {outfile}'),
344− ('text/x-sass', '/run/current-system/sw/bin/sassc -t compressed {infile} {outfile}'),
345−)
346−# On a production setup, setting COMPRESS_OFFLINE to True will bring a
347−# significant performance improvement, as CSS files will not need to be
348−# recompiled on each requests. It means running an additional "compress"
349−# management command after each code upgrade.
350−# http://django-compressor.readthedocs.io/en/latest/usage/#offline-compression
351−COMPRESS_ENABLED = True
352−COMPRESS_OFFLINE = True
353−
354−# Needed for debug mode
355−# INTERNAL_IPS = ('127.0.0.1',)
356−
357−
358−#
359−# Full-text search engine
360−#
361−HAYSTACK_CONNECTIONS = {
362− 'default': {
363− 'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
364− 'PATH': "/var/lib/mailman-web/fulltext_index",
365− # You can also use the Xapian engine, it's faster and more accurate,
366− # but requires another library.
367− # http://django-haystack.readthedocs.io/en/v2.4.1/installing_search_engines.html#xapian
368− # Example configuration for Xapian:
369− #'ENGINE': 'xapian_backend.XapianEngine'
370− },
371−}
372−
373−
374−#
375−# REST framework
376−#
377−REST_FRAMEWORK = {
378− 'PAGE_SIZE': 10,
379− 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination',
380− 'DEFAULT_FILTER_BACKENDS': (
381− 'rest_framework.filters.OrderingFilter',
382− ),
383−}
384−
385−
386−#
387−# Asynchronous tasks
388−#
389−Q_CLUSTER = {
390− 'timeout': 300,
391− 'save_limit': 100,
392− 'orm': 'default',
393−}
394−
395−
396−# A sample logging configuration. The only tangible logging
397−# performed by this configuration is to send an email to
398−# the site admins on every HTTP 500 error when DEBUG=False.
399−# See http://docs.djangoproject.com/en/dev/topics/logging for
400−# more details on how to customize your logging configuration.
401−LOGGING = {
402− 'version': 1,
403− 'disable_existing_loggers': False,
404− 'filters': {
405− 'require_debug_false': {
406− '()': 'django.utils.log.RequireDebugFalse'
407− }
408− },
409− 'handlers': {
410− 'console': {
411− 'class': 'logging.StreamHandler',
412− 'formatter': 'simple',
413− },
414− 'mail_admins': {
415− 'level': 'ERROR',
416− 'filters': ['require_debug_false'],
417− 'class': 'django.utils.log.AdminEmailHandler'
418− },
419− 'file':{
420− 'level': 'INFO',
421− #'class': 'logging.handlers.RotatingFileHandler',
422− 'class': 'logging.handlers.WatchedFileHandler',
423− 'filename': 'mailman-web.log',
424− 'formatter': 'verbose',
425− },
426− },
427− 'loggers': {
428− 'django': {
429− 'handlers': ['console', 'file'],
430− 'level': 'INFO',
431− },
432− 'django.request': {
433− 'handlers': ['console', 'mail_admins', 'file'],
434− 'level': 'ERROR',
435− 'propagate': True,
436− },
437− 'postorius': {
438− 'handlers': ['console', 'file'],
439− 'level': 'INFO',
440− },
441− 'django': {
442− 'handlers': ['file'],
443− 'level': 'ERROR',
444− 'propagate': True,
445− },
446− 'hyperkitty': {
447− 'handlers': ['file'],
448− 'level': 'DEBUG',
449− 'propagate': True,
450− },
451− },
452− 'formatters': {
453− 'simple': {
454− 'format': '%(levelname)s: %(message)s'
455− },
456− 'verbose': {
457− 'format': '%(levelname)s %(asctime)s %(process)d %(name)s %(message)s'
458− },
459− 'simple': {
460− 'format': '%(levelname)s %(message)s'
461− },
462− },
463− #'root': {
464− # 'handlers': ['file'],
465− # 'level': 'INFO',
466− #},
467−}
468−
469−
470−POSTORIUS_TEMPLATE_BASE_URL = "http://localhost:8000"
471−
472−
473−# Using the cache infrastructure can significantly improve performance on a
474−# production setup. This is an example with a local Memcached server.
475−#CACHES = {
476−# 'default': {
477−# 'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
478−# 'LOCATION': '127.0.0.1:11211',
479−# }
480−#}
481−
482−
483−# When DEBUG is True, don't actually send emails to the SMTP server, just store
484−# them in a directory. This way you won't accidentally spam your mailing-lists
485−# while you're fiddling with the code.
486−if DEBUG == True:
487− EMAIL_BACKEND = 'django.core.mail.backends.filebased.EmailBackend'
488− EMAIL_FILE_PATH = '/tmp/hyperkitty-emails'
489−
490−
491−#
492−# HyperKitty-specific
493−#
494−# Only display mailing-lists from the same virtual host as the webserver
495−FILTER_VHOST = False
496−# Disable singleton locking for Django-Q tasks.
497−HYPERKITTY_DISABLE_SINGLETON_TASKS = False
498−# Maximum time between two task runs with same function and arguments.
499−# This setting is mostly meant for Mailman Developers and should be used
500−# with caution.
501−# Default set to 10mins.
502−HYPERKITTY_TASK_LOCK_TIMEOUT = 10 * 60
503−
504−
505−try:
506− from settings_local import *
507−except ImportError:
508− pass
pkgs/servers/mail/mailman/urls.pydeleted−34
@@ -1,34 +0,0 @@
1−# -*- coding: utf-8 -*-
2−# Copyright (C) 1998-2019 by the Free Software Foundation, Inc.
3−#
4−# This file is part of Postorius.
5−#
6−# Postorius is free software: you can redistribute it and/or modify it under
7−# the terms of the GNU General Public License as published by the Free
8−# Software Foundation, either version 3 of the License, or (at your option)
9−# any later version.
10−#
11−# Postorius is distributed in the hope that it will be useful, but WITHOUT
12−# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13−# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14−# more details.
15−#
16−# You should have received a copy of the GNU General Public License along with
17−# Postorius. If not, see <http://www.gnu.org/licenses/>.
18−
19−
20−from django.conf.urls import include, url
21−from django.contrib import admin
22−from django.urls import reverse_lazy
23−from django.views.generic import RedirectView
24−
25−
26−urlpatterns = [
27− url(r'^$', RedirectView.as_view(url=reverse_lazy('hk_root'))),
28− url(r'^hyperkitty/', include('hyperkitty.urls')),
29− url(r'^postorius/', include('postorius.urls')),
30− url(r'', include('django_mailman3.urls')),
31− url(r'^accounts/', include('allauth.urls')),
32− # Django admin
33− url(r'^admin/', admin.site.urls),
34−]
pkgs/servers/mail/mailman/web.nix+31−30
@@ -1,38 +1,39 @@
1−{ stdenv, python, hyperkitty, postorius, buildPythonPackage, isPy3k
2−, serverEMail ? "postmaster@example.org"
3−, archiverKey ? "SecretArchiverAPIKey"
4−, allowedHosts ? []
1+{ buildPythonPackage, lib, fetchgit, isPy3k
2+, git, makeWrapper, sassc, hyperkitty, postorius, whoosh
53}:
64
7−let
8−
9− allowedHostsString = stdenv.lib.concatMapStringsSep ", " (x: "\""+x+"\"") allowedHosts;
10−
11−in
12−
13−# We turn those Djando configuration files into a make-shift Python library so
14−# that Nix users can use this package as a part of their buildInputs to import
15−# the code. Also, this package implicitly provides an environment in which the
16−# Django app can be run.
17−
18−buildPythonPackage {
19− name = "mailman-web-0";
5+buildPythonPackage rec {
6+ pname = "mailman-web-unstable";
7+ version = "2019-09-29";
208 disabled = !isPy3k;
219
22− propagatedBuildInputs = [ hyperkitty postorius ];
10+ src = fetchgit {
11+ url = "https://gitlab.com/mailman/mailman-web";
12+ rev = "d17203b4d6bdc71c2b40891757f57a32f3de53d5";
13+ sha256 = "124cxr4vfi1ibgxygk4l74q4fysx0a6pga1kk9p5wq2yvzwg9z3n";
14+ leaveDotGit = true;
15+ };
16+
17+ # This is just so people installing from pip also get uwsgi
18+ # installed, AFAICT.
19+ postPatch = ''
20+ sed -i '/^ uwsgi$/d' setup.cfg
21+ '';
22+
23+ nativeBuildInputs = [ git makeWrapper ];
24+ propagatedBuildInputs = [ hyperkitty postorius whoosh ];
2325
24− unpackPhase = ":";
25− buildPhase = ":";
26− setuptoolsCheckPhase = ":";
26+ # Tries to check runtime configuration.
27+ doCheck = false;
2728
28− installPhase = ''
29− d=$out/${python.sitePackages}
30− install -D -m 444 ${./urls.py} $d/urls.py
31− install -D -m 444 ${./wsgi.py} $d/wsgi.py
32− substitute ${./settings.py} $d/settings.py \
33− --subst-var-by SERVER_EMAIL '${serverEMail}' \
34− --subst-var-by ARCHIVER_KEY '${archiverKey}' \
35− --subst-var-by ALLOWED_HOSTS '${allowedHostsString}'
36− chmod 444 $d/settings.py
29+ postInstall = ''
30+ wrapProgram $out/bin/mailman-web \
31+ --suffix PATH : ${lib.makeBinPath [ sassc ]}
3732 '';
33+
34+ meta = with lib; {
35+ description = "Django project for Mailman 3 web interface";
36+ license = licenses.gpl3;
37+ maintainers = with maintainers; [ qyliss ];
38+ };
3839}
pkgs/servers/mail/mailman/wsgi.pydeleted−17
@@ -1,17 +0,0 @@
1−"""
2−WSGI config for meh project.
3−
4−It exposes the WSGI callable as a module-level variable named ``application``.
5−
6−For more information on this file, see
7−https://docs.djangoproject.com/en/1.9/howto/deployment/wsgi/
8−"""
9−
10−import os
11−
12−from django.core.wsgi import get_wsgi_application
13−
14−
15−os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
16−
17−application = get_wsgi_application()
pkgs/top-level/all-packages.nix+2
@@ -15325,6 +15325,8 @@ in
1532515325
1532615326 mailman-rss = callPackage ../development/python-modules/mailman-rss { };
1532715327
15328+ mailman-web = with python3.pkgs; toPythonApplication mailman-web;
15329+
1532815330 mattermost = callPackage ../servers/mattermost { };
1532915331 matterircd = callPackage ../servers/mattermost/matterircd.nix { };
1533015332 matterbridge = callPackage ../servers/matterbridge { };