1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
|
{ env, makeWrapper, stdenv, writeText, fetchurl, buildBowerComponents, fetchedGit, fetchedGithub, which, python3, pkgs, automake, autoconf, nodejs, nodePackages, git, cacert }:
let
plugins = {
basicsearch = stdenv.mkDerivation (fetchedGithub ./mediagoblin-plugin-basicsearch.json // rec {
phases = "unpackPhase installPhase";
installPhase = ''
cp -R . $out
'';
});
};
overridePython = let
packageOverrides = self: super: {
celery = super.celery.overridePythonAttrs(old: rec {
version = "3.1.26.post2";
src = self.fetchPypi {
inherit version;
inherit (old) pname;
sha256 = "5493e172ae817b81ba7d09443ada114886765a8ce02f16a56e6fac68d953a9b2";
};
patches = [];
doCheck = false;
});
billiard = super.billiard.overridePythonAttrs(old: rec {
version = "3.3.0.23";
src = self.fetchPypi {
inherit version;
inherit (old) pname;
sha256 = "02wxsc6bhqvzh8j6w758kvgqbnj14l796mvmrcms8fgfamd2lak9";
};
});
amqp = super.amqp.overridePythonAttrs(old: rec {
version = "1.4.9";
src = self.fetchPypi {
inherit version;
inherit (old) pname;
sha256 = "2dea4d16d073c902c3b89d9b96620fb6729ac0f7a923bbc777cb4ad827c0c61a";
};
});
kombu = super.kombu.overridePythonAttrs(old: rec {
version = "3.0.37";
src = self.fetchPypi {
inherit version;
inherit (old) pname;
sha256 = "e064a00c66b4d1058cd2b0523fb8d98c82c18450244177b6c0f7913016642650";
};
propagatedBuildInputs = old.propagatedBuildInputs ++ [ self.anyjson ];
doCheck = false;
});
sqlalchemy = super.sqlalchemy.overridePythonAttrs(old: rec {
version = "1.1.18";
src = self.fetchPypi {
inherit version;
inherit (old) pname;
sha256 = "8b0ec71af9291191ba83a91c03d157b19ab3e7119e27da97932a4773a3f664a9";
};
});
tempita_5_3_dev = super.buildPythonPackage (fetchedGithub ./tempita.json // rec {
buildInputs = with self; [ nose ];
disabled = false;
});
sqlalchemy_migrate = super.sqlalchemy_migrate.overridePythonAttrs(old: rec {
propagatedBuildInputs = with self; [ pbr tempita_5_3_dev decorator sqlalchemy six sqlparse ];
});
pasteScript = super.pasteScript.overridePythonAttrs(old: rec {
version = "2.0.2";
name = "PasteScript-${version}";
src = fetchurl {
url = "mirror://pypi/P/PasteScript/${name}.tar.gz";
sha256 = "1h3nnhn45kf4pbcv669ik4faw04j58k8vbj1hwrc532k0nc28gy0";
};
propagatedBuildInputs = with self; [ six paste PasteDeploy argparse ];
});
};
in
python3.override { inherit packageOverrides; };
pythonEnv = python-pkgs: with python-pkgs; [
waitress alembic dateutil wtforms pybcrypt
pytest pytest_xdist werkzeug celery
kombu jinja2 Babel webtest configobj markdown
sqlalchemy itsdangerous pytz sphinx six
oauthlib unidecode jsonschema PasteDeploy
requests PyLD exifread
typing pasteScript
# For images plugin
pillow
# For video plugin
gst-python
# migrations
sqlalchemy_migrate
# authentication
ldap3
redis
psycopg2
];
python = overridePython.withPackages pythonEnv;
gmg = writeText "gmg" ''
#!${python}/bin/python
__requires__ = 'mediagoblin'
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.exit(
load_entry_point('mediagoblin', 'console_scripts', 'gmg')()
)
'';
in
rec {
socketsDir = "/run/mediagoblin";
varDir = "/var/lib/mediagoblin";
bowerComponents = buildBowerComponents {
name = "mediagoblin-bower-components";
generated = ./bower-packages.nix;
src = (fetchedGit ./mediagoblin.json).src;
};
mediagoblin = stdenv.mkDerivation (fetchedGit ./mediagoblin.json // rec {
preConfigure = ''
# ./bootstrap.sh
aclocal -I m4 --install
autoreconf -fvi
# end
export GIT_SSL_CAINFO=${cacert}/etc/ssl/certs/ca-bundle.crt
export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt
export HOME=$PWD
'';
configureFlags = [ "--with-python3" "--without-virtualenv" ];
postBuild = ''
cp -a ${bowerComponents}/bower_components/* extlib
chmod -R u+w extlib
make extlib
'';
installPhase = ''
sed -i "s/registry.has_key(current_theme_name)/current_theme_name in registry/" mediagoblin/tools/theme.py
sed -i -e "s@\[DEFAULT\]@[DEFAULT]\nhere = $out@" mediagoblin/config_spec.ini
cp ${./ldap_fix.py} mediagoblin/plugins/ldap/tools.py
ln -s ${plugins.basicsearch}/basicsearch mediagoblin/plugins/basicsearch
find . -name '*.pyc' -delete
find . -type f -exec sed -i "s|$PWD|$out|g" {} \;
python setup.py build
cp -a . $out
mkdir $out/bin
cp ${gmg} $out/bin/gmg
chmod a+x $out/bin/gmg
'';
buildInputs = [ makeWrapper git cacert automake autoconf which nodePackages.bower nodejs python ];
propagatedBuildInputs = [ python ];
});
paste_local = writeText "paste_local.ini" ''
[DEFAULT]
debug = false
[pipeline:main]
pipeline = mediagoblin
[app:mediagoblin]
use = egg:mediagoblin#app
config = %(here)s/mediagoblin_local.ini %(here)s/mediagoblin.ini
/mgoblin_static = %(here)s/mediagoblin/static
[loggers]
keys = root
[handlers]
keys = console
[formatters]
keys = generic
[logger_root]
level = INFO
handlers = console
[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic
[formatter_generic]
format = %(levelname)-7.7s [%(name)s] %(message)s
[filter:errors]
use = egg:mediagoblin#errors
debug = false
[server:main]
use = egg:waitress#main
unix_socket = ${socketsDir}/mediagoblin.sock
unix_socket_perms = 777
url_scheme = https
'';
mediagoblin_local = writeText "mediagoblin_local.ini" ''
[DEFAULT]
data_basedir = "${varDir}"
[mediagoblin]
direct_remote_path = /mgoblin_static/
email_sender_address = "mediagoblin@mail.immae.eu"
#sql_engine = sqlite:///%(data_basedir)s/mediagoblin.db
sql_engine = ${env.psql_url}
email_debug_mode = false
allow_registration = false
allow_reporting = true
theme = airymodified
user_privilege_scheme = "uploader,commenter,reporter"
# We need to redefine them here since we override data_basedir
# cf /usr/share/webapps/mediagoblin/mediagoblin/config_spec.ini
workbench_path = %(data_basedir)s/media/workbench
crypto_path = %(data_basedir)s/crypto
theme_install_dir = %(data_basedir)s/themes/
theme_linked_assets_dir = %(data_basedir)s/theme_static/
plugin_linked_assets_dir = %(data_basedir)s/plugin_static/
[storage:queuestore]
base_dir = %(data_basedir)s/media/queue
[storage:publicstore]
base_dir = %(data_basedir)s/media/public
base_url = /mgoblin_media/
[celery]
CELERY_RESULT_DBURI = redis+socket:///run/redis/redis.sock?virtual_host=12
BROKER_URL = redis+socket:///run/redis/redis.sock?virtual_host=12
CELERYD_CONCURRENCY = 1
[plugins]
[[mediagoblin.plugins.geolocation]]
[[mediagoblin.plugins.ldap]]
[[[immae.eu]]]
LDAP_SERVER_URI = 'ldaps://ldap.immae.eu:636'
LDAP_SEARCH_BASE = 'dc=immae,dc=eu'
LDAP_BIND_DN = 'cn=mediagoblin,ou=services,dc=immae,dc=eu'
LDAP_BIND_PW = '${env.ldap.password}'
LDAP_SEARCH_FILTER = '(&(memberOf=cn=users,cn=mediagoblin,ou=services,dc=immae,dc=eu)(uid={username}))'
EMAIL_SEARCH_FIELD = 'mail'
[[mediagoblin.plugins.basicsearch]]
[[mediagoblin.plugins.piwigo]]
[[mediagoblin.plugins.processing_info]]
[[mediagoblin.media_types.image]]
[[mediagoblin.media_types.video]]
'';
pythonRoot =
with pkgs.gst_all_1;
stdenv.mkDerivation {
name = "mediagoblin_immae";
inherit mediagoblin;
buildInputs= [ makeWrapper ];
propagatedBuildInputs = [ gst-libav gst-plugins-good gst-plugins-bad gst-plugins-ugly gstreamer ];
builder = let
libpaths = [
python
gstreamer
gst-plugins-base
gst-libav
gst-plugins-good
gst-plugins-bad
gst-plugins-ugly
];
plugin_paths = builtins.concatStringsSep ":" (map (x: "${x}/lib") libpaths);
typelib_paths = "${gstreamer}/lib/girepository-1.0:${gst-plugins-base}/lib/girepository-1.0";
in writeText "build_mediagoblin_immae" ''
source $stdenv/setup
cp -a $mediagoblin $out
cd $out
chmod -R u+rwX .
sed -i -e "/from gi.repository import GstPbutils/s/^/gi.require_version('GstPbutils', '1.0')\n/" mediagoblin/media_types/video/transcoders.py
wrapProgram bin/gmg --prefix PYTHONPATH : "$out:$PYTHONPATH" \
--prefix GST_PLUGIN_SYSTEM_PATH : ${plugin_paths} \
--prefix GI_TYPELIB_PATH : ${typelib_paths}
makeWrapper ${python}/bin/paster bin/paster --prefix PYTHONPATH : "$out:$PYTHONPATH" \
--prefix GST_PLUGIN_SYSTEM_PATH : ${plugin_paths} \
--prefix GI_TYPELIB_PATH : ${typelib_paths}
makeWrapper ${python}/bin/celery bin/celery --prefix PYTHONPATH : "$out:$PYTHONPATH" \
--prefix GST_PLUGIN_SYSTEM_PATH : ${plugin_paths} \
--prefix GI_TYPELIB_PATH : ${typelib_paths}
find . -type f -exec sed -i "s|$mediagoblin|$out|g" {} \;
ln -s ${paste_local} ./paste_local.ini
ln -s ${mediagoblin_local} ./mediagoblin_local.ini
ln -sf ../../../../../${varDir} ./user_dev
'';
};
}
|