]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - nixops/modules/websites/tools/ether/etherpad_lite.nix
Move etherpad and mediagoblin keys to secure location
[perso/Immae/Config/Nix.git] / nixops / modules / websites / tools / ether / etherpad_lite.nix
CommitLineData
17146204
IB
1{ env, fetchedGithub, fetchurl, stdenv, writeText, pkgs, cacert }:
2let
bfe3c9c9 3 listenPort = env.listenPort;
17146204
IB
4 sessionkey = writeText "SESSIONKEY.txt" env.session_key;
5 apikey = writeText "APIKEY.txt" env.api_key;
6 jquery = fetchurl {
7 url = https://code.jquery.com/jquery-1.9.1.js;
8 sha256 = "0h4dk67yc9d0kadqxb6b33585f3x3559p6qmp70l00qwq030vn3v";
9 };
10 etherpad_modules = [
11 "ep_aa_file_menu_toolbar"
12 "ep_adminpads"
13 "ep_align"
14 "ep_bookmark"
15 "ep_clear_formatting"
16 "ep_colors"
17 "ep_copy_paste_select_all"
18 "ep_cursortrace"
19 "ep_embedmedia"
20 "ep_font_family"
21 "ep_font_size"
22 "ep_headings2"
23 "ep_ldapauth"
24 "ep_line_height"
25 "ep_markdown"
26 "ep_previewimages"
27 "ep_ruler"
28 "ep_scrollto"
29 "ep_set_title_on_pad"
30 "ep_subscript_and_superscript"
31 "ep_timesliderdiff"
32 ];
51900e34
IB
33 keys.tools-etherpad = {
34 destDir = "/run/keys/webapps";
35 permissions = "0400";
36 text =
37 # Make sure we’re not rebuilding whole libreoffice just because of a
38 # dependency
39 let libreoffice = (import <nixpkgs> {}).libreoffice-fresh;
40 in
41 ''
42 {
43 "title": "Etherpad",
44 "favicon": "favicon.ico",
17146204 45
51900e34
IB
46 "ip": "127.0.0.1",
47 "port" : ${env.listenPort},
48 "showSettingsInAdminPage" : false,
49 "dbType" : "postgres",
50 "dbSettings" : {
51 "user" : "${env.postgresql.user}",
52 "host" : "${env.postgresql.socket}",
53 "password": "${env.postgresql.password}",
54 "database": "${env.postgresql.database}",
55 "charset" : "utf8mb4"
56 },
17146204 57
51900e34
IB
58 "defaultPadText" : "Welcome to Etherpad!\n\nThis pad text is synchronized as you type, so that everyone viewing this page sees the same text. This allows you to collaborate seamlessly on documents!\n\nGet involved with Etherpad at http:\/\/etherpad.org\n",
59 "padOptions": {
60 "noColors": false,
61 "showControls": true,
62 "showChat": true,
63 "showLineNumbers": true,
64 "useMonospaceFont": false,
65 "userName": false,
66 "userColor": false,
67 "rtl": false,
68 "alwaysShowChat": false,
69 "chatAndUsers": false,
70 "lang": "en-gb"
71 },
17146204 72
51900e34
IB
73 "suppressErrorsInPadText" : false,
74 "requireSession" : false,
75 "editOnly" : false,
76 "sessionNoPassword" : false,
77 "minify" : true,
78 "maxAge" : 21600,
79 "abiword" : null,
80 "soffice" : "${libreoffice}/bin/soffice",
81 "tidyHtml" : "${pkgs.html-tidy}/bin/tidy",
82 "allowUnknownFileEnds" : true,
83 "requireAuthentication" : false,
84 "requireAuthorization" : false,
85 "trustProxy" : false,
86 "disableIPlogging" : false,
87 "automaticReconnectionTimeout" : 0,
88 "scrollWhenFocusLineIsOutOfViewport": {
89 "percentage": {
90 "editionAboveViewport": 0,
91 "editionBelowViewport": 0
92 },
93 "duration": 0,
94 "scrollWhenCaretIsInTheLastLineOfViewport": false,
95 "percentageToScrollWhenUserPressesArrowUp": 0
17146204 96 },
51900e34
IB
97 "users": {
98 "ldapauth": {
99 "url": "ldaps://${env.ldap.host}",
100 "accountBase": "${env.ldap.base}",
101 "accountPattern": "(&(memberOf=cn=users,cn=etherpad,ou=services,dc=immae,dc=eu)(uid={{username}}))",
102 "displayNameAttribute": "cn",
103 "searchDN": "cn=etherpad,ou=services,dc=immae,dc=eu",
104 "searchPWD": "${env.ldap.password}",
105 "groupSearchBase": "${env.ldap.base}",
106 "groupAttribute": "member",
107 "groupAttributeIsDN": true,
108 "searchScope": "sub",
109 "groupSearch": "(memberOf=cn=groups,cn=etherpad,ou=services,dc=immae,dc=eu)",
110 "anonymousReadonly": false
111 }
112 },
113 "socketTransportProtocols" : ["xhr-polling", "jsonp-polling", "htmlfile"],
114 "loadTest": false,
115 "indentationOnNewLine": false,
116 "toolbar": {
117 "left": [
118 ["bold", "italic", "underline", "strikethrough"],
119 ["orderedlist", "unorderedlist", "indent", "outdent"],
120 ["undo", "redo"],
121 ["clearauthorship"]
122 ],
123 "right": [
124 ["importexport", "timeslider", "savedrevision"],
125 ["settings", "embed"],
126 ["showusers"]
127 ],
128 "timeslider": [
129 ["timeslider_export", "timeslider_returnToPad"]
130 ]
131 },
132 "loglevel": "INFO",
133 "logconfig" : { "appenders": [ { "type": "console" } ] }
134 }
135 '';
136 };
17146204
IB
137 webappDir = stdenv.mkDerivation (fetchedGithub ./etherpad-lite.json // rec {
138 __noChroot = true;
139 patches = [ ./libreoffice_patch.diff ];
140 buildPhase = ''
141 export GIT_SSL_CAINFO=${cacert}/etc/ssl/certs/ca-bundle.crt
142 export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt
143 export HOME=$PWD
144
145 touch src/.ep_initialized
146 cp -v src/static/custom/js.template src/static/custom/index.js
147 cp -v src/static/custom/js.template src/static/custom/pad.js
148 cp -v src/static/custom/js.template src/static/custom/timeslider.js
149 cp -v src/static/custom/css.template src/static/custom/index.css
150 cp -v src/static/custom/css.template src/static/custom/pad.css
151 cp -v src/static/custom/css.template src/static/custom/timeslider.css
152
153 sed -i 's/var\/dirty.db/\/var\/lib\/etherpad-lite\/dirty.db/g' \
154 settings.json.template
155
156 mkdir -v node_modules
157 ln -s ../src node_modules/ep_etherpad-lite
158
159 node bin/doc/generate doc/index.md --format=html \
160 --template=doc/template.html > documentation.html
161
162 cd src
163 npm install
164 cd ..
165 ${builtins.concatStringsSep "\n"
166 (map (n: "npm install ${n}; touch node_modules/${n}/.ep_initialized") etherpad_modules)}
167 '';
168 installPhase = ''
169 mkdir -p $out
170 install -t $out/src/ -vDm 644 src/.ep_initialized
171 cp -a node_modules $out/
172 cp -a src/* $out/src/
173 ln -sf ${sessionkey} $out/SESSIONKEY.txt
174 ln -sf ${apikey} $out/APIKEY.txt
175 cp ${jquery} $out/src/static/js/jquery.js
176
177 mkdir $out/doc
178 install -t "$out/doc/" \
179 -vDm 644 {CHANGELOG,CONTRIBUTING,README}.md \
180 -vDm 644 documentation.html
181 '';
182 buildInputs = [ pkgs.nodejs pkgs.python ];
183 });
184in
185 {
51900e34 186 inherit webappDir keys listenPort;
17146204 187 }