aboutsummaryrefslogtreecommitdiff
path: root/pkgs
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2019-05-07 01:50:22 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2019-05-07 08:41:51 +0200
commitddd3f845089062716d7fc64e5a5e4e413363df91 (patch)
treea8557606e92456e4f71148d3c6668c4c349e376e /pkgs
parent7da817e32f5e285f5fe09726f6031d8c6d4c74ea (diff)
downloadNix-ddd3f845089062716d7fc64e5a5e4e413363df91.tar.gz
Nix-ddd3f845089062716d7fc64e5a5e4e413363df91.tar.zst
Nix-ddd3f845089062716d7fc64e5a5e4e413363df91.zip
Move mediagoblin to pkgs
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/webapps/default.nix8
-rw-r--r--pkgs/webapps/mediagoblin/bower-packages.nix8
-rw-r--r--pkgs/webapps/mediagoblin/default.nix167
-rw-r--r--pkgs/webapps/mediagoblin/ldap_fix.py93
-rw-r--r--pkgs/webapps/mediagoblin/mediagoblin.json14
-rw-r--r--pkgs/webapps/mediagoblin/plugins/basicsearch/default.nix18
-rw-r--r--pkgs/webapps/mediagoblin/tempita.json15
7 files changed, 323 insertions, 0 deletions
diff --git a/pkgs/webapps/default.nix b/pkgs/webapps/default.nix
index 3b9cadf..84e46bd 100644
--- a/pkgs/webapps/default.nix
+++ b/pkgs/webapps/default.nix
@@ -44,4 +44,12 @@ rec {
44 (name: callPackage (./dokuwiki/plugins + "/${name}.nix") {}); 44 (name: callPackage (./dokuwiki/plugins + "/${name}.nix") {});
45 45
46 adminer = callPackage ./adminer {}; 46 adminer = callPackage ./adminer {};
47
48 mediagoblin = callPackage ./mediagoblin { inherit mylibs; };
49 mediagoblin-with-plugins = mediagoblin.withPlugins (builtins.attrValues mediagoblin-plugins);
50 mediagoblin-plugins = let
51 names = [ "basicsearch" ];
52 in
53 lib.attrsets.genAttrs names
54 (name: callPackage (./mediagoblin/plugins + "/${name}") {});
47} 55}
diff --git a/pkgs/webapps/mediagoblin/bower-packages.nix b/pkgs/webapps/mediagoblin/bower-packages.nix
new file mode 100644
index 0000000..03af849
--- /dev/null
+++ b/pkgs/webapps/mediagoblin/bower-packages.nix
@@ -0,0 +1,8 @@
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/pkgs/webapps/mediagoblin/default.nix b/pkgs/webapps/mediagoblin/default.nix
new file mode 100644
index 0000000..e1ca898
--- /dev/null
+++ b/pkgs/webapps/mediagoblin/default.nix
@@ -0,0 +1,167 @@
1{ makeWrapper, stdenv, writeScript, fetchurl, buildBowerComponents, mylibs, which, python36, gst_all_1, automake, autoconf, nodejs, nodePackages }:
2let
3 overridePython = let
4 packageOverrides = self: super: {
5 celery = super.celery.overridePythonAttrs(old: rec {
6 version = "3.1.26.post2";
7 src = self.fetchPypi {
8 inherit version;
9 inherit (old) pname;
10 sha256 = "5493e172ae817b81ba7d09443ada114886765a8ce02f16a56e6fac68d953a9b2";
11 };
12 patches = [];
13 doCheck = false;
14 });
15 billiard = super.billiard.overridePythonAttrs(old: rec {
16 version = "3.3.0.23";
17 src = self.fetchPypi {
18 inherit version;
19 inherit (old) pname;
20 sha256 = "02wxsc6bhqvzh8j6w758kvgqbnj14l796mvmrcms8fgfamd2lak9";
21 };
22 });
23 amqp = super.amqp.overridePythonAttrs(old: rec {
24 version = "1.4.9";
25 src = self.fetchPypi {
26 inherit version;
27 inherit (old) pname;
28 sha256 = "2dea4d16d073c902c3b89d9b96620fb6729ac0f7a923bbc777cb4ad827c0c61a";
29 };
30 });
31 kombu = super.kombu.overridePythonAttrs(old: rec {
32 version = "3.0.37";
33 src = self.fetchPypi {
34 inherit version;
35 inherit (old) pname;
36 sha256 = "e064a00c66b4d1058cd2b0523fb8d98c82c18450244177b6c0f7913016642650";
37 };
38 propagatedBuildInputs = old.propagatedBuildInputs ++ [ self.anyjson ];
39 doCheck = false;
40 });
41 sqlalchemy = super.sqlalchemy.overridePythonAttrs(old: rec {
42 version = "1.1.18";
43 src = self.fetchPypi {
44 inherit version;
45 inherit (old) pname;
46 sha256 = "8b0ec71af9291191ba83a91c03d157b19ab3e7119e27da97932a4773a3f664a9";
47 };
48 });
49 tempita_5_3_dev = super.buildPythonPackage (mylibs.fetchedGithub ./tempita.json // rec {
50 buildInputs = with self; [ nose ];
51 disabled = false;
52 });
53 sqlalchemy_migrate = super.sqlalchemy_migrate.overridePythonAttrs(old: rec {
54 propagatedBuildInputs = with self; [ pbr tempita_5_3_dev decorator sqlalchemy six sqlparse ];
55 });
56 pasteScript = super.pasteScript.overridePythonAttrs(old: rec {
57 version = "2.0.2";
58 name = "PasteScript-${version}";
59 src = fetchurl {
60 url = "mirror://pypi/P/PasteScript/${name}.tar.gz";
61 sha256 = "1h3nnhn45kf4pbcv669ik4faw04j58k8vbj1hwrc532k0nc28gy0";
62 };
63 propagatedBuildInputs = with self; [ six paste PasteDeploy ];
64 });
65 };
66 in
67 python36.override { inherit packageOverrides; };
68 pythonEnv = python-pkgs: with python-pkgs; [
69 waitress alembic dateutil wtforms pybcrypt
70 pytest pytest_xdist werkzeug celery
71 kombu jinja2 Babel webtest configobj markdown
72 sqlalchemy itsdangerous pytz sphinx six
73 oauthlib unidecode jsonschema PasteDeploy
74 requests PyLD exifread
75 typing pasteScript lxml
76 # For images plugin
77 pillow
78 # For video plugin
79 gst-python
80 # migrations
81 sqlalchemy_migrate
82 # authentication
83 ldap3
84 redis
85 psycopg2
86 ];
87 python = overridePython.withPackages pythonEnv;
88 gmg = writeScript "gmg" ''
89 #!${python}/bin/python
90 __requires__ = 'mediagoblin'
91 import sys
92 from pkg_resources import load_entry_point
93
94 if __name__ == '__main__':
95 sys.exit(
96 load_entry_point('mediagoblin', 'console_scripts', 'gmg')()
97 )
98 '';
99 bowerComponents = buildBowerComponents {
100 name = "mediagoblin-bower-components";
101 generated = ./bower-packages.nix;
102 src = (mylibs.fetchedGit ./mediagoblin.json).src;
103 };
104 withPlugins = plugins: package.overrideAttrs(old: {
105 name = "${old.name}-with-plugins";
106 postBuild = old.postBuild + (
107 builtins.concatStringsSep "\n" (
108 map (value: "ln -s ${value} mediagoblin/plugins/${value.pluginName}") plugins
109 )
110 );
111 passthru.plugins = plugins;
112 passthru.withPlugins = morePlugins: old.withPlugins (morePlugins ++ plugins);
113 });
114 package = stdenv.mkDerivation (mylibs.fetchedGit ./mediagoblin.json // rec {
115 preConfigure = ''
116 # ./bootstrap.sh
117 aclocal -I m4 --install
118 autoreconf -fvi
119 # end
120 export HOME=$PWD
121 '';
122 configureFlags = [ "--with-python3" "--without-virtualenv" ];
123 postBuild = ''
124 cp -a ${bowerComponents}/bower_components/* extlib
125 chmod -R u+w extlib
126 make extlib
127 '';
128 installPhase = let
129 libpaths = with gst_all_1; [
130 python
131 gstreamer
132 gst-plugins-base
133 gst-libav
134 gst-plugins-good
135 gst-plugins-bad
136 gst-plugins-ugly
137 ];
138 plugin_paths = builtins.concatStringsSep ":" (map (x: "${x}/lib") libpaths);
139 typelib_paths = with gst_all_1; "${gstreamer}/lib/girepository-1.0:${gst-plugins-base}/lib/girepository-1.0";
140 in ''
141 sed -i "s/registry.has_key(current_theme_name)/current_theme_name in registry/" mediagoblin/tools/theme.py
142 sed -i -e "s@\[DEFAULT\]@[DEFAULT]\nhere = $out@" mediagoblin/config_spec.ini
143 sed -i -e "/from gi.repository import GstPbutils/s/^/gi.require_version('GstPbutils', '1.0')\n/" mediagoblin/media_types/video/transcoders.py
144 cp ${./ldap_fix.py} mediagoblin/plugins/ldap/tools.py
145 find . -name '*.pyc' -delete
146 find . -type f -exec sed -i "s|$PWD|$out|g" {} \;
147 python setup.py build
148 cp -a . $out
149 mkdir $out/bin
150 makeWrapper ${gmg} $out/bin/gmg --prefix PYTHONPATH : "$out:$PYTHONPATH" \
151 --prefix GST_PLUGIN_SYSTEM_PATH : ${plugin_paths} \
152 --prefix GI_TYPELIB_PATH : ${typelib_paths}
153 makeWrapper ${python}/bin/paster $out/bin/paster --prefix PYTHONPATH : "$out:$PYTHONPATH" \
154 --prefix GST_PLUGIN_SYSTEM_PATH : ${plugin_paths} \
155 --prefix GI_TYPELIB_PATH : ${typelib_paths}
156 makeWrapper ${python}/bin/celery $out/bin/celery --prefix PYTHONPATH : "$out:$PYTHONPATH" \
157 --prefix GST_PLUGIN_SYSTEM_PATH : ${plugin_paths} \
158 --prefix GI_TYPELIB_PATH : ${typelib_paths}
159 '';
160 buildInputs = [ makeWrapper automake autoconf which nodePackages.bower nodejs python ];
161 propagatedBuildInputs = with gst_all_1; [ python gst-libav gst-plugins-good gst-plugins-bad gst-plugins-ugly gstreamer ];
162 passthru = {
163 plugins = [];
164 inherit withPlugins;
165 };
166 });
167in package
diff --git a/pkgs/webapps/mediagoblin/ldap_fix.py b/pkgs/webapps/mediagoblin/ldap_fix.py
new file mode 100644
index 0000000..10cc375
--- /dev/null
+++ b/pkgs/webapps/mediagoblin/ldap_fix.py
@@ -0,0 +1,93 @@
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/pkgs/webapps/mediagoblin/mediagoblin.json b/pkgs/webapps/mediagoblin/mediagoblin.json
new file mode 100644
index 0000000..7ea72d1
--- /dev/null
+++ b/pkgs/webapps/mediagoblin/mediagoblin.json
@@ -0,0 +1,14 @@
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/pkgs/webapps/mediagoblin/plugins/basicsearch/default.nix b/pkgs/webapps/mediagoblin/plugins/basicsearch/default.nix
new file mode 100644
index 0000000..16be613
--- /dev/null
+++ b/pkgs/webapps/mediagoblin/plugins/basicsearch/default.nix
@@ -0,0 +1,18 @@
1{ stdenv, fetchFromGitHub }:
2stdenv.mkDerivation rec {
3 name = "mediagoblin-plugin-basicsearch-${version}";
4 version = "ba0a154-master";
5 src = fetchFromGitHub {
6 owner = "ayleph";
7 repo = "mediagoblin-basicsearch";
8 rev = "ba0a1547bd24ebaf363227fe17644d38c6ce8a6b";
9 sha256 = "0d4r7xkf4gxmgaxlb264l44xbanis77g49frwfhfzsflxmdwgncy";
10 };
11 phases = "unpackPhase installPhase";
12 installPhase = ''
13 cp -R ./basicsearch $out
14 '';
15 passthru = {
16 pluginName = "basicsearch";
17 };
18}
diff --git a/pkgs/webapps/mediagoblin/tempita.json b/pkgs/webapps/mediagoblin/tempita.json
new file mode 100644
index 0000000..5371e17
--- /dev/null
+++ b/pkgs/webapps/mediagoblin/tempita.json
@@ -0,0 +1,15 @@
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}