aboutsummaryrefslogtreecommitdiff
path: root/nixops/modules/websites/tools/mediagoblin
diff options
context:
space:
mode:
Diffstat (limited to 'nixops/modules/websites/tools/mediagoblin')
-rw-r--r--nixops/modules/websites/tools/mediagoblin/bower-packages.nix8
-rw-r--r--nixops/modules/websites/tools/mediagoblin/default.nix171
-rw-r--r--nixops/modules/websites/tools/mediagoblin/ldap_fix.py93
-rw-r--r--nixops/modules/websites/tools/mediagoblin/mediagoblin-plugin-basicsearch.json15
-rw-r--r--nixops/modules/websites/tools/mediagoblin/mediagoblin.json14
-rw-r--r--nixops/modules/websites/tools/mediagoblin/mediagoblin.nix294
-rw-r--r--nixops/modules/websites/tools/mediagoblin/tempita.json15
7 files changed, 138 insertions, 472 deletions
diff --git a/nixops/modules/websites/tools/mediagoblin/bower-packages.nix b/nixops/modules/websites/tools/mediagoblin/bower-packages.nix
deleted file mode 100644
index 03af849..0000000
--- a/nixops/modules/websites/tools/mediagoblin/bower-packages.nix
+++ /dev/null
@@ -1,8 +0,0 @@
1# Generated by bower2nix v3.2.0 (https://github.com/rvl/bower2nix)
2{ fetchbower, buildEnv }:
3buildEnv { name = "bower-env"; ignoreCollisions = true; paths = [
4 (fetchbower "jquery" "2.1.4" "~2.1.3" "1ywrpk2xsr6ghkm3j9gfnl9r3jn6xarfamp99b0bcm57kq9fm2k0")
5 (fetchbower "video.js" "4.11.4" "~4.11.4" "05prdvyk0rxbkh7sdd0d9ns5l5crwvc68wzkyqmrdjw367pcv8sn")
6 (fetchbower "leaflet" "0.7.7" "~0.7.3" "0jim285bljmxxngpm3yx6bnnd10n2whwkgmmhzpcd1rdksnr5nca")
7 (fetchbower "tinymce" "4.1.10" "~4.1.7" "16jyvdb9bq8gjwhs69q8p88vdixalajrz81nsmbrzzxhkih57dyx")
8]; }
diff --git a/nixops/modules/websites/tools/mediagoblin/default.nix b/nixops/modules/websites/tools/mediagoblin/default.nix
index 36329d9..a02af38 100644
--- a/nixops/modules/websites/tools/mediagoblin/default.nix
+++ b/nixops/modules/websites/tools/mediagoblin/default.nix
@@ -1,18 +1,123 @@
1{ lib, pkgs, config, myconfig, mylibs, ... }: 1{ lib, pkgs, config, myconfig, mylibs, ... }:
2let 2let
3 mediagoblin = pkgs.callPackage ./mediagoblin.nix { 3 env = myconfig.env.tools.mediagoblin;
4 inherit (mylibs) fetchedGit fetchedGithub; 4 socketsDir = "/run/mediagoblin";
5 env = myconfig.env.tools.mediagoblin; 5 varDir = "/var/lib/mediagoblin";
6 };
7
8 cfg = config.services.myWebsites.tools.mediagoblin; 6 cfg = config.services.myWebsites.tools.mediagoblin;
7 mediagoblin_init = "/var/secrets/webapps/tools-mediagoblin";
8 paste_local = pkgs.writeText "paste_local.ini" ''
9 [DEFAULT]
10 debug = false
11
12 [pipeline:main]
13 pipeline = mediagoblin
14
15 [app:mediagoblin]
16 use = egg:mediagoblin#app
17 config = ${mediagoblin_init} ${pythonRoot}/mediagoblin.ini
18 /mgoblin_static = ${pythonRoot}/mediagoblin/static
19
20 [loggers]
21 keys = root
22
23 [handlers]
24 keys = console
25
26 [formatters]
27 keys = generic
28
29 [logger_root]
30 level = INFO
31 handlers = console
32
33 [handler_console]
34 class = StreamHandler
35 args = (sys.stderr,)
36 level = NOTSET
37 formatter = generic
38
39 [formatter_generic]
40 format = %(levelname)-7.7s [%(name)s] %(message)s
41
42 [filter:errors]
43 use = egg:mediagoblin#errors
44 debug = false
45
46 [server:main]
47 use = egg:waitress#main
48 unix_socket = ${socketsDir}/mediagoblin.sock
49 unix_socket_perms = 777
50 url_scheme = https
51 '';
52 pythonRoot = pkgs.webapps.mediagoblin-with-plugins;
9in { 53in {
10 options.services.myWebsites.tools.mediagoblin = { 54 options.services.myWebsites.tools.mediagoblin = {
11 enable = lib.mkEnableOption "enable mediagoblin's website"; 55 enable = lib.mkEnableOption "enable mediagoblin's website";
12 }; 56 };
13 57
14 config = lib.mkIf cfg.enable { 58 config = lib.mkIf cfg.enable {
15 mySecrets.keys = mediagoblin.keys; 59 mySecrets.keys = [{
60 dest = "webapps/tools-mediagoblin";
61 user = "mediagoblin";
62 group = "mediagoblin";
63 permissions = "0400";
64 text = ''
65 [DEFAULT]
66 data_basedir = "${varDir}"
67
68 [mediagoblin]
69 direct_remote_path = /mgoblin_static/
70 email_sender_address = "mediagoblin@tools.immae.eu"
71
72 #sql_engine = sqlite:///%(data_basedir)s/mediagoblin.db
73 sql_engine = ${env.psql_url}
74
75 email_debug_mode = false
76 allow_registration = false
77 allow_reporting = true
78
79 theme = airymodified
80
81 user_privilege_scheme = "uploader,commenter,reporter"
82
83 # We need to redefine them here since we override data_basedir
84 # cf /usr/share/webapps/mediagoblin/mediagoblin/config_spec.ini
85 workbench_path = %(data_basedir)s/media/workbench
86 crypto_path = %(data_basedir)s/crypto
87 theme_install_dir = %(data_basedir)s/themes/
88 theme_linked_assets_dir = %(data_basedir)s/theme_static/
89 plugin_linked_assets_dir = %(data_basedir)s/plugin_static/
90
91 [storage:queuestore]
92 base_dir = %(data_basedir)s/media/queue
93
94 [storage:publicstore]
95 base_dir = %(data_basedir)s/media/public
96 base_url = /mgoblin_media/
97
98 [celery]
99 CELERY_RESULT_DBURI = ${env.redis_url}
100 BROKER_URL = ${env.redis_url}
101 CELERYD_CONCURRENCY = 1
102
103 [plugins]
104 [[mediagoblin.plugins.geolocation]]
105 [[mediagoblin.plugins.ldap]]
106 [[[immae.eu]]]
107 LDAP_SERVER_URI = 'ldaps://ldap.immae.eu:636'
108 LDAP_SEARCH_BASE = 'dc=immae,dc=eu'
109 LDAP_BIND_DN = 'cn=mediagoblin,ou=services,dc=immae,dc=eu'
110 LDAP_BIND_PW = '${env.ldap.password}'
111 LDAP_SEARCH_FILTER = '(&(memberOf=cn=users,cn=mediagoblin,ou=services,dc=immae,dc=eu)(uid={username}))'
112 EMAIL_SEARCH_FIELD = 'mail'
113 [[mediagoblin.plugins.basicsearch]]
114 [[mediagoblin.plugins.piwigo]]
115 [[mediagoblin.plugins.processing_info]]
116 [[mediagoblin.media_types.image]]
117 [[mediagoblin.media_types.video]]
118 '';
119 }];
120
16 ids.uids.mediagoblin = myconfig.env.tools.mediagoblin.user.uid; 121 ids.uids.mediagoblin = myconfig.env.tools.mediagoblin.user.uid;
17 ids.gids.mediagoblin = myconfig.env.tools.mediagoblin.user.gid; 122 ids.gids.mediagoblin = myconfig.env.tools.mediagoblin.user.gid;
18 123
@@ -21,7 +126,7 @@ in {
21 uid = config.ids.uids.mediagoblin; 126 uid = config.ids.uids.mediagoblin;
22 group = "mediagoblin"; 127 group = "mediagoblin";
23 description = "Mediagoblin user"; 128 description = "Mediagoblin user";
24 home = mediagoblin.varDir; 129 home = varDir;
25 useDefaultShell = true; 130 useDefaultShell = true;
26 extraGroups = [ "keys" ]; 131 extraGroups = [ "keys" ];
27 }; 132 };
@@ -38,17 +143,17 @@ in {
38 143
39 script = '' 144 script = ''
40 exec ./bin/paster serve \ 145 exec ./bin/paster serve \
41 ${mediagoblin.pythonRoot}/paste_local.ini \ 146 ${paste_local} \
42 --pid-file=${mediagoblin.socketsDir}/mediagoblin.pid 147 --pid-file=${socketsDir}/mediagoblin.pid
43 ''; 148 '';
44 149
45 preStop = '' 150 preStop = ''
46 exec ./bin/paster serve \ 151 exec ./bin/paster serve \
47 --pid-file=${mediagoblin.socketsDir}/mediagoblin.pid \ 152 --pid-file=${socketsDir}/mediagoblin.pid \
48 ${mediagoblin.pythonRoot}/paste_local.ini stop 153 ${paste_local} stop
49 ''; 154 '';
50 preStart = '' 155 preStart = ''
51 ./bin/gmg dbupdate 156 ./bin/gmg -cf ${mediagoblin_init} dbupdate
52 ''; 157 '';
53 158
54 serviceConfig = { 159 serviceConfig = {
@@ -57,11 +162,11 @@ in {
57 Restart = "always"; 162 Restart = "always";
58 TimeoutSec = 15; 163 TimeoutSec = 15;
59 Type = "simple"; 164 Type = "simple";
60 WorkingDirectory = mediagoblin.pythonRoot; 165 WorkingDirectory = pythonRoot;
61 PIDFile = "${mediagoblin.socketsDir}/mediagoblin.pid"; 166 PIDFile = "${socketsDir}/mediagoblin.pid";
62 }; 167 };
63 168
64 unitConfig.RequiresMountsFor = mediagoblin.varDir; 169 unitConfig.RequiresMountsFor = varDir;
65 }; 170 };
66 171
67 systemd.services.mediagoblin-celeryd = { 172 systemd.services.mediagoblin-celeryd = {
@@ -69,12 +174,12 @@ in {
69 wantedBy = [ "multi-user.target" ]; 174 wantedBy = [ "multi-user.target" ];
70 after = [ "network.target" "mediagoblin-web.service" ]; 175 after = [ "network.target" "mediagoblin-web.service" ];
71 176
72 environment.MEDIAGOBLIN_CONFIG = "${mediagoblin.pythonRoot}/mediagoblin_local.ini"; 177 environment.MEDIAGOBLIN_CONFIG = "${pythonRoot}/mediagoblin_local.ini";
73 environment.CELERY_CONFIG_MODULE = "mediagoblin.init.celery.from_celery"; 178 environment.CELERY_CONFIG_MODULE = "mediagoblin.init.celery.from_celery";
74 179
75 script = '' 180 script = ''
76 exec ./bin/celery worker \ 181 exec ./bin/celery worker \
77 --logfile=${mediagoblin.varDir}/celery.log \ 182 --logfile=${varDir}/celery.log \
78 --loglevel=INFO 183 --loglevel=INFO
79 ''; 184 '';
80 185
@@ -84,21 +189,21 @@ in {
84 Restart = "always"; 189 Restart = "always";
85 TimeoutSec = 60; 190 TimeoutSec = 60;
86 Type = "simple"; 191 Type = "simple";
87 WorkingDirectory = mediagoblin.pythonRoot; 192 WorkingDirectory = pythonRoot;
88 PIDFile = "${mediagoblin.socketsDir}/mediagoblin-celeryd.pid"; 193 PIDFile = "${socketsDir}/mediagoblin-celeryd.pid";
89 }; 194 };
90 195
91 unitConfig.RequiresMountsFor = mediagoblin.varDir; 196 unitConfig.RequiresMountsFor = varDir;
92 }; 197 };
93 198
94 system.activationScripts.mediagoblin = { 199 system.activationScripts.mediagoblin = {
95 deps = [ "users" ]; 200 deps = [ "users" ];
96 text = '' 201 text = ''
97 install -m 0755 -o mediagoblin -g mediagoblin -d ${mediagoblin.socketsDir} 202 install -m 0755 -o mediagoblin -g mediagoblin -d ${socketsDir}
98 install -m 0755 -o mediagoblin -g mediagoblin -d ${mediagoblin.varDir} 203 install -m 0755 -o mediagoblin -g mediagoblin -d ${varDir}
99 if [ -d ${mediagoblin.varDir}/plugin_static/ ]; then 204 if [ -d ${varDir}/plugin_static/ ]; then
100 rm ${mediagoblin.varDir}/plugin_static/coreplugin_basic_auth 205 rm ${varDir}/plugin_static/coreplugin_basic_auth
101 ln -sf ${mediagoblin.pythonRoot}/mediagoblin/plugins/basic_auth/static ${mediagoblin.varDir}/plugin_static/coreplugin_basic_auth 206 ln -sf ${pythonRoot}/mediagoblin/plugins/basic_auth/static ${varDir}/plugin_static/coreplugin_basic_auth
102 fi 207 fi
103 ''; 208 '';
104 }; 209 };
@@ -113,20 +218,20 @@ in {
113 hosts = ["mgoblin.immae.eu" ]; 218 hosts = ["mgoblin.immae.eu" ];
114 root = null; 219 root = null;
115 extraConfig = [ '' 220 extraConfig = [ ''
116 Alias /mgoblin_media ${mediagoblin.varDir}/media/public 221 Alias /mgoblin_media ${varDir}/media/public
117 <Directory ${mediagoblin.varDir}/media/public> 222 <Directory ${varDir}/media/public>
118 Options -Indexes +FollowSymLinks +MultiViews +Includes 223 Options -Indexes +FollowSymLinks +MultiViews +Includes
119 Require all granted 224 Require all granted
120 </Directory> 225 </Directory>
121 226
122 Alias /theme_static ${mediagoblin.varDir}/theme_static 227 Alias /theme_static ${varDir}/theme_static
123 <Directory ${mediagoblin.varDir}/theme_static> 228 <Directory ${varDir}/theme_static>
124 Options -Indexes +FollowSymLinks +MultiViews +Includes 229 Options -Indexes +FollowSymLinks +MultiViews +Includes
125 Require all granted 230 Require all granted
126 </Directory> 231 </Directory>
127 232
128 Alias /plugin_static ${mediagoblin.varDir}/plugin_static 233 Alias /plugin_static ${varDir}/plugin_static
129 <Directory ${mediagoblin.varDir}/plugin_static> 234 <Directory ${varDir}/plugin_static>
130 Options -Indexes +FollowSymLinks +MultiViews +Includes 235 Options -Indexes +FollowSymLinks +MultiViews +Includes
131 Require all granted 236 Require all granted
132 </Directory> 237 </Directory>
@@ -138,8 +243,8 @@ in {
138 ProxyPass /theme_static ! 243 ProxyPass /theme_static !
139 ProxyPass /plugin_static ! 244 ProxyPass /plugin_static !
140 ProxyPassMatch ^/.well-known/acme-challenge ! 245 ProxyPassMatch ^/.well-known/acme-challenge !
141 ProxyPass / unix://${mediagoblin.socketsDir}/mediagoblin.sock|http://mgoblin.immae.eu/ 246 ProxyPass / unix://${socketsDir}/mediagoblin.sock|http://mgoblin.immae.eu/
142 ProxyPassReverse / unix://${mediagoblin.socketsDir}/mediagoblin.sock|http://mgoblin.immae.eu/ 247 ProxyPassReverse / unix://${socketsDir}/mediagoblin.sock|http://mgoblin.immae.eu/
143 '' ]; 248 '' ];
144 }; 249 };
145 }; 250 };
diff --git a/nixops/modules/websites/tools/mediagoblin/ldap_fix.py b/nixops/modules/websites/tools/mediagoblin/ldap_fix.py
deleted file mode 100644
index 10cc375..0000000
--- a/nixops/modules/websites/tools/mediagoblin/ldap_fix.py
+++ /dev/null
@@ -1,93 +0,0 @@
1# GNU MediaGoblin -- federated, autonomous media hosting
2# Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS.
3#
4# This program is free software: you can redistribute it and/or modify
5# it under the terms of the GNU Affero General Public License as published by
6# the Free Software Foundation, either version 3 of the License, or
7# (at your option) any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU Affero General Public License for more details.
13#
14# You should have received a copy of the GNU Affero General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16from ldap3 import Server, Connection, SUBTREE
17from ldap3.core.exceptions import LDAPException
18import logging
19
20import six
21
22from mediagoblin.tools import pluginapi
23
24_log = logging.getLogger(__name__)
25
26
27class LDAP(object):
28 def __init__(self):
29 self.ldap_settings = pluginapi.get_config('mediagoblin.plugins.ldap')
30
31 def _connect(self, server):
32 _log.info('Connecting to {0}.'.format(server['LDAP_SERVER_URI']))
33 self.server = Server(server['LDAP_SERVER_URI'])
34
35 if 'LDAP_START_TLS' in server and server['LDAP_START_TLS'] == 'true':
36 _log.info('Initiating TLS')
37 self.server.start_tls()
38
39 def _manager_auth(self, settings, username, password):
40 conn = Connection(self.server,
41 settings['LDAP_BIND_DN'],
42 settings['LDAP_BIND_PW'],
43 auto_bind=True)
44 found = conn.search(
45 search_base=settings['LDAP_SEARCH_BASE'],
46 search_filter=settings['LDAP_SEARCH_FILTER'].format(username=username),
47 search_scope=SUBTREE,
48 attributes=[settings['EMAIL_SEARCH_FIELD']])
49 if (not found) or len(conn.entries) > 1:
50 return False, None
51
52 user = conn.entries[0]
53 user_dn = user.entry_dn
54 try:
55 email = user.entry_attributes_as_dict[settings['EMAIL_SEARCH_FIELD']][0]
56 except KeyError:
57 email = None
58
59 Connection(self.server, user_dn, password, auto_bind=True)
60
61 return username, email
62
63 def _direct_auth(self, settings, username, password):
64 user_dn = settings['LDAP_USER_DN_TEMPLATE'].format(username=username)
65 conn = Connection(self.server, user_dn, password, auto_bind=True)
66 email_found = conn.search(
67 search_base=settings['LDAP_SEARCH_BASE'],
68 search_filter='uid={0}'.format(username),
69 search_scope=SUBTREE,
70 attributes=[settings['EMAIL_SEARCH_FIELD']])
71
72 if email_found:
73 try:
74 email = conn.entries[0].entry_attributes_as_dict[settings['EMAIL_SEARCH_FIELD']][0]
75 except KeyError:
76 email = None
77
78 return username, email
79
80 def login(self, username, password):
81 for k, v in six.iteritems(self.ldap_settings):
82 try:
83 self._connect(v)
84
85 if 'LDAP_BIND_DN' in v:
86 return self._manager_auth(v, username, password)
87 else:
88 return self._direct_auth(v, username, password)
89
90 except LDAPException as e:
91 _log.info(e)
92
93 return False, None
diff --git a/nixops/modules/websites/tools/mediagoblin/mediagoblin-plugin-basicsearch.json b/nixops/modules/websites/tools/mediagoblin/mediagoblin-plugin-basicsearch.json
deleted file mode 100644
index 9abd994..0000000
--- a/nixops/modules/websites/tools/mediagoblin/mediagoblin-plugin-basicsearch.json
+++ /dev/null
@@ -1,15 +0,0 @@
1{
2 "tag": "ba0a154-master",
3 "meta": {
4 "name": "mediagoblin-plugin-basicsearch",
5 "url": "https://github.com/ayleph/mediagoblin-basicsearch",
6 "branch": "master"
7 },
8 "github": {
9 "owner": "ayleph",
10 "repo": "mediagoblin-basicsearch",
11 "rev": "ba0a1547bd24ebaf363227fe17644d38c6ce8a6b",
12 "sha256": "0d4r7xkf4gxmgaxlb264l44xbanis77g49frwfhfzsflxmdwgncy",
13 "fetchSubmodules": true
14 }
15}
diff --git a/nixops/modules/websites/tools/mediagoblin/mediagoblin.json b/nixops/modules/websites/tools/mediagoblin/mediagoblin.json
deleted file mode 100644
index 7ea72d1..0000000
--- a/nixops/modules/websites/tools/mediagoblin/mediagoblin.json
+++ /dev/null
@@ -1,14 +0,0 @@
1{
2 "tag": "cd465eb-stable",
3 "meta": {
4 "name": "mediagoblin",
5 "url": "git://git.savannah.gnu.org/mediagoblin.git",
6 "branch": "stable"
7 },
8 "git": {
9 "url": "git://git.savannah.gnu.org/mediagoblin.git",
10 "rev": "cd465ebfec837a75a44c4ebd727dffe2fff6d850",
11 "sha256": "1yz4i4i97z3rxl534a6psaybyjbyp5nnc52v3nvbpzc4pd2s69mx",
12 "fetchSubmodules": true
13 }
14}
diff --git a/nixops/modules/websites/tools/mediagoblin/mediagoblin.nix b/nixops/modules/websites/tools/mediagoblin/mediagoblin.nix
deleted file mode 100644
index bc423db..0000000
--- a/nixops/modules/websites/tools/mediagoblin/mediagoblin.nix
+++ /dev/null
@@ -1,294 +0,0 @@
1{ env, makeWrapper, stdenv, writeText, fetchurl, buildBowerComponents, fetchedGit, fetchedGithub, which, python36, pkgs, automake, autoconf, nodejs, nodePackages, git, cacert }:
2let
3 plugins = {
4 basicsearch = stdenv.mkDerivation (fetchedGithub ./mediagoblin-plugin-basicsearch.json // rec {
5 phases = "unpackPhase installPhase";
6 installPhase = ''
7 cp -R . $out
8 '';
9 });
10 };
11 overridePython = let
12 packageOverrides = self: super: {
13 celery = super.celery.overridePythonAttrs(old: rec {
14 version = "3.1.26.post2";
15 src = self.fetchPypi {
16 inherit version;
17 inherit (old) pname;
18 sha256 = "5493e172ae817b81ba7d09443ada114886765a8ce02f16a56e6fac68d953a9b2";
19 };
20 patches = [];
21 doCheck = false;
22 });
23 billiard = super.billiard.overridePythonAttrs(old: rec {
24 version = "3.3.0.23";
25 src = self.fetchPypi {
26 inherit version;
27 inherit (old) pname;
28 sha256 = "02wxsc6bhqvzh8j6w758kvgqbnj14l796mvmrcms8fgfamd2lak9";
29 };
30 });
31 amqp = super.amqp.overridePythonAttrs(old: rec {
32 version = "1.4.9";
33 src = self.fetchPypi {
34 inherit version;
35 inherit (old) pname;
36 sha256 = "2dea4d16d073c902c3b89d9b96620fb6729ac0f7a923bbc777cb4ad827c0c61a";
37 };
38 });
39 kombu = super.kombu.overridePythonAttrs(old: rec {
40 version = "3.0.37";
41 src = self.fetchPypi {
42 inherit version;
43 inherit (old) pname;
44 sha256 = "e064a00c66b4d1058cd2b0523fb8d98c82c18450244177b6c0f7913016642650";
45 };
46 propagatedBuildInputs = old.propagatedBuildInputs ++ [ self.anyjson ];
47 doCheck = false;
48 });
49 sqlalchemy = super.sqlalchemy.overridePythonAttrs(old: rec {
50 version = "1.1.18";
51 src = self.fetchPypi {
52 inherit version;
53 inherit (old) pname;
54 sha256 = "8b0ec71af9291191ba83a91c03d157b19ab3e7119e27da97932a4773a3f664a9";
55 };
56 });
57 tempita_5_3_dev = super.buildPythonPackage (fetchedGithub ./tempita.json // rec {
58 buildInputs = with self; [ nose ];
59 disabled = false;
60 });
61 sqlalchemy_migrate = super.sqlalchemy_migrate.overridePythonAttrs(old: rec {
62 propagatedBuildInputs = with self; [ pbr tempita_5_3_dev decorator sqlalchemy six sqlparse ];
63 });
64 pasteScript = super.pasteScript.overridePythonAttrs(old: rec {
65 version = "2.0.2";
66 name = "PasteScript-${version}";
67 src = fetchurl {
68 url = "mirror://pypi/P/PasteScript/${name}.tar.gz";
69 sha256 = "1h3nnhn45kf4pbcv669ik4faw04j58k8vbj1hwrc532k0nc28gy0";
70 };
71 propagatedBuildInputs = with self; [ six paste PasteDeploy ];
72 });
73 };
74 in
75 python36.override { inherit packageOverrides; };
76 pythonEnv = python-pkgs: with python-pkgs; [
77 waitress alembic dateutil wtforms pybcrypt
78 pytest pytest_xdist werkzeug celery
79 kombu jinja2 Babel webtest configobj markdown
80 sqlalchemy itsdangerous pytz sphinx six
81 oauthlib unidecode jsonschema PasteDeploy
82 requests PyLD exifread
83 typing pasteScript lxml
84 # For images plugin
85 pillow
86 # For video plugin
87 gst-python
88 # migrations
89 sqlalchemy_migrate
90 # authentication
91 ldap3
92 redis
93 psycopg2
94 ];
95 python = overridePython.withPackages pythonEnv;
96 gmg = writeText "gmg" ''
97 #!${python}/bin/python
98 __requires__ = 'mediagoblin'
99 import sys
100 from pkg_resources import load_entry_point
101
102 if __name__ == '__main__':
103 sys.exit(
104 load_entry_point('mediagoblin', 'console_scripts', 'gmg')()
105 )
106 '';
107in
108 rec {
109 socketsDir = "/run/mediagoblin";
110 varDir = "/var/lib/mediagoblin";
111 bowerComponents = buildBowerComponents {
112 name = "mediagoblin-bower-components";
113 generated = ./bower-packages.nix;
114 src = (fetchedGit ./mediagoblin.json).src;
115 };
116 mediagoblin = stdenv.mkDerivation (fetchedGit ./mediagoblin.json // rec {
117 preConfigure = ''
118 # ./bootstrap.sh
119 aclocal -I m4 --install
120 autoreconf -fvi
121 # end
122 export GIT_SSL_CAINFO=${cacert}/etc/ssl/certs/ca-bundle.crt
123 export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt
124 export HOME=$PWD
125 '';
126 configureFlags = [ "--with-python3" "--without-virtualenv" ];
127 postBuild = ''
128 cp -a ${bowerComponents}/bower_components/* extlib
129 chmod -R u+w extlib
130 make extlib
131 '';
132 installPhase = ''
133 sed -i "s/registry.has_key(current_theme_name)/current_theme_name in registry/" mediagoblin/tools/theme.py
134 sed -i -e "s@\[DEFAULT\]@[DEFAULT]\nhere = $out@" mediagoblin/config_spec.ini
135 cp ${./ldap_fix.py} mediagoblin/plugins/ldap/tools.py
136 ln -s ${plugins.basicsearch}/basicsearch mediagoblin/plugins/basicsearch
137 find . -name '*.pyc' -delete
138 find . -type f -exec sed -i "s|$PWD|$out|g" {} \;
139 python setup.py build
140 cp -a . $out
141 mkdir $out/bin
142 cp ${gmg} $out/bin/gmg
143 chmod a+x $out/bin/gmg
144 '';
145 buildInputs = [ makeWrapper git cacert automake autoconf which nodePackages.bower nodejs python ];
146 propagatedBuildInputs = [ python ];
147 });
148 paste_local = writeText "paste_local.ini" ''
149 [DEFAULT]
150 debug = false
151
152 [pipeline:main]
153 pipeline = mediagoblin
154
155 [app:mediagoblin]
156 use = egg:mediagoblin#app
157 config = %(here)s/mediagoblin_local.ini %(here)s/mediagoblin.ini
158 /mgoblin_static = %(here)s/mediagoblin/static
159
160 [loggers]
161 keys = root
162
163 [handlers]
164 keys = console
165
166 [formatters]
167 keys = generic
168
169 [logger_root]
170 level = INFO
171 handlers = console
172
173 [handler_console]
174 class = StreamHandler
175 args = (sys.stderr,)
176 level = NOTSET
177 formatter = generic
178
179 [formatter_generic]
180 format = %(levelname)-7.7s [%(name)s] %(message)s
181
182 [filter:errors]
183 use = egg:mediagoblin#errors
184 debug = false
185
186 [server:main]
187 use = egg:waitress#main
188 unix_socket = ${socketsDir}/mediagoblin.sock
189 unix_socket_perms = 777
190 url_scheme = https
191 '';
192
193 keys = [{
194 dest = "webapps/tools-mediagoblin";
195 user = "mediagoblin";
196 group = "mediagoblin";
197 permissions = "0400";
198 text = ''
199 [DEFAULT]
200 data_basedir = "${varDir}"
201
202 [mediagoblin]
203 direct_remote_path = /mgoblin_static/
204 email_sender_address = "mediagoblin@tools.immae.eu"
205
206 #sql_engine = sqlite:///%(data_basedir)s/mediagoblin.db
207 sql_engine = ${env.psql_url}
208
209 email_debug_mode = false
210 allow_registration = false
211 allow_reporting = true
212
213 theme = airymodified
214
215 user_privilege_scheme = "uploader,commenter,reporter"
216
217 # We need to redefine them here since we override data_basedir
218 # cf /usr/share/webapps/mediagoblin/mediagoblin/config_spec.ini
219 workbench_path = %(data_basedir)s/media/workbench
220 crypto_path = %(data_basedir)s/crypto
221 theme_install_dir = %(data_basedir)s/themes/
222 theme_linked_assets_dir = %(data_basedir)s/theme_static/
223 plugin_linked_assets_dir = %(data_basedir)s/plugin_static/
224
225 [storage:queuestore]
226 base_dir = %(data_basedir)s/media/queue
227
228 [storage:publicstore]
229 base_dir = %(data_basedir)s/media/public
230 base_url = /mgoblin_media/
231
232 [celery]
233 CELERY_RESULT_DBURI = ${env.redis_url}
234 BROKER_URL = ${env.redis_url}
235 CELERYD_CONCURRENCY = 1
236
237 [plugins]
238 [[mediagoblin.plugins.geolocation]]
239 [[mediagoblin.plugins.ldap]]
240 [[[immae.eu]]]
241 LDAP_SERVER_URI = 'ldaps://ldap.immae.eu:636'
242 LDAP_SEARCH_BASE = 'dc=immae,dc=eu'
243 LDAP_BIND_DN = 'cn=mediagoblin,ou=services,dc=immae,dc=eu'
244 LDAP_BIND_PW = '${env.ldap.password}'
245 LDAP_SEARCH_FILTER = '(&(memberOf=cn=users,cn=mediagoblin,ou=services,dc=immae,dc=eu)(uid={username}))'
246 EMAIL_SEARCH_FIELD = 'mail'
247 [[mediagoblin.plugins.basicsearch]]
248 [[mediagoblin.plugins.piwigo]]
249 [[mediagoblin.plugins.processing_info]]
250 [[mediagoblin.media_types.image]]
251 [[mediagoblin.media_types.video]]
252 '';
253 }];
254 pythonRoot =
255 with pkgs.gst_all_1;
256 stdenv.mkDerivation {
257 name = "mediagoblin_immae";
258 inherit mediagoblin;
259 buildInputs= [ makeWrapper ];
260 propagatedBuildInputs = [ gst-libav gst-plugins-good gst-plugins-bad gst-plugins-ugly gstreamer ];
261 builder = let
262 libpaths = [
263 python
264 gstreamer
265 gst-plugins-base
266 gst-libav
267 gst-plugins-good
268 gst-plugins-bad
269 gst-plugins-ugly
270 ];
271 plugin_paths = builtins.concatStringsSep ":" (map (x: "${x}/lib") libpaths);
272 typelib_paths = "${gstreamer}/lib/girepository-1.0:${gst-plugins-base}/lib/girepository-1.0";
273 in writeText "build_mediagoblin_immae" ''
274 source $stdenv/setup
275 cp -a $mediagoblin $out
276 cd $out
277 chmod -R u+rwX .
278 sed -i -e "/from gi.repository import GstPbutils/s/^/gi.require_version('GstPbutils', '1.0')\n/" mediagoblin/media_types/video/transcoders.py
279 wrapProgram bin/gmg --prefix PYTHONPATH : "$out:$PYTHONPATH" \
280 --prefix GST_PLUGIN_SYSTEM_PATH : ${plugin_paths} \
281 --prefix GI_TYPELIB_PATH : ${typelib_paths}
282 makeWrapper ${python}/bin/paster bin/paster --prefix PYTHONPATH : "$out:$PYTHONPATH" \
283 --prefix GST_PLUGIN_SYSTEM_PATH : ${plugin_paths} \
284 --prefix GI_TYPELIB_PATH : ${typelib_paths}
285 makeWrapper ${python}/bin/celery bin/celery --prefix PYTHONPATH : "$out:$PYTHONPATH" \
286 --prefix GST_PLUGIN_SYSTEM_PATH : ${plugin_paths} \
287 --prefix GI_TYPELIB_PATH : ${typelib_paths}
288 find . -type f -exec sed -i "s|$mediagoblin|$out|g" {} \;
289 ln -s ${paste_local} ./paste_local.ini
290 ln -s /var/secrets/webapps/tools-mediagoblin ./mediagoblin_local.ini
291 ln -sf ${varDir} ./user_dev
292 '';
293 };
294 }
diff --git a/nixops/modules/websites/tools/mediagoblin/tempita.json b/nixops/modules/websites/tools/mediagoblin/tempita.json
deleted file mode 100644
index 5371e17..0000000
--- a/nixops/modules/websites/tools/mediagoblin/tempita.json
+++ /dev/null
@@ -1,15 +0,0 @@
1{
2 "tag": "47414a7-master",
3 "meta": {
4 "name": "tempita",
5 "url": "https://github.com/gjhiggins/tempita",
6 "branch": "master"
7 },
8 "github": {
9 "owner": "gjhiggins",
10 "repo": "tempita",
11 "rev": "47414a7c6e46a9a9afe78f0bce2ea299fa84d10d",
12 "sha256": "0f33jjjs5rvp7ar2j6ggyfykcrsrn04jaqcq71qfvycf6b7nw3rn",
13 "fetchSubmodules": true
14 }
15}