X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=nixops%2Fmodules%2Fwebsites%2Ftools%2Fether%2Fetherpad_lite.nix;h=35220eee210e3ae67674dcfc748c51992ee9409a;hb=a8bfce17c5eda890d3486357952572f4c1c6b18a;hp=bc622625b1b702f4154d5432780513111799d11a;hpb=51900e3488284b0711083819a5ecb1b0f280a913;p=perso%2FImmae%2FConfig%2FNix.git diff --git a/nixops/modules/websites/tools/ether/etherpad_lite.nix b/nixops/modules/websites/tools/ether/etherpad_lite.nix index bc62262..35220ee 100644 --- a/nixops/modules/websites/tools/ether/etherpad_lite.nix +++ b/nixops/modules/websites/tools/ether/etherpad_lite.nix @@ -1,186 +1,128 @@ -{ env, fetchedGithub, fetchurl, stdenv, writeText, pkgs, cacert }: +{ env, etherpad-lite, etherpad-lite-modules, writeText, pkgs }: let listenPort = env.listenPort; sessionkey = writeText "SESSIONKEY.txt" env.session_key; apikey = writeText "APIKEY.txt" env.api_key; - jquery = fetchurl { - url = https://code.jquery.com/jquery-1.9.1.js; - sha256 = "0h4dk67yc9d0kadqxb6b33585f3x3559p6qmp70l00qwq030vn3v"; - }; - etherpad_modules = [ - "ep_aa_file_menu_toolbar" - "ep_adminpads" - "ep_align" - "ep_bookmark" - "ep_clear_formatting" - "ep_colors" - "ep_copy_paste_select_all" - "ep_cursortrace" - "ep_embedmedia" - "ep_font_family" - "ep_font_size" - "ep_headings2" - "ep_ldapauth" - "ep_line_height" - "ep_markdown" - "ep_previewimages" - "ep_ruler" - "ep_scrollto" - "ep_set_title_on_pad" - "ep_subscript_and_superscript" - "ep_timesliderdiff" - ]; - keys.tools-etherpad = { - destDir = "/run/keys/webapps"; - permissions = "0400"; - text = - # Make sure we’re not rebuilding whole libreoffice just because of a - # dependency - let libreoffice = (import {}).libreoffice-fresh; - in - '' - { - "title": "Etherpad", - "favicon": "favicon.ico", + keys = [ + { + dest = "webapps/tools-etherpad-apikey"; + permissions = "0400"; + text = env.api_key; + } + { + dest = "webapps/tools-etherpad-sessionkey"; + permissions = "0400"; + text = env.session_key; + } + { + dest = "webapps/tools-etherpad"; + permissions = "0400"; + text = + # Make sure we’re not rebuilding whole libreoffice just because of a + # dependency + let libreoffice = (import { overlays = []; }).libreoffice-fresh; + in + '' + { + "title": "Etherpad", + "favicon": "favicon.ico", - "ip": "127.0.0.1", - "port" : ${env.listenPort}, - "showSettingsInAdminPage" : false, - "dbType" : "postgres", - "dbSettings" : { - "user" : "${env.postgresql.user}", - "host" : "${env.postgresql.socket}", - "password": "${env.postgresql.password}", - "database": "${env.postgresql.database}", - "charset" : "utf8mb4" - }, - - "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", - "padOptions": { - "noColors": false, - "showControls": true, - "showChat": true, - "showLineNumbers": true, - "useMonospaceFont": false, - "userName": false, - "userColor": false, - "rtl": false, - "alwaysShowChat": false, - "chatAndUsers": false, - "lang": "en-gb" - }, - - "suppressErrorsInPadText" : false, - "requireSession" : false, - "editOnly" : false, - "sessionNoPassword" : false, - "minify" : true, - "maxAge" : 21600, - "abiword" : null, - "soffice" : "${libreoffice}/bin/soffice", - "tidyHtml" : "${pkgs.html-tidy}/bin/tidy", - "allowUnknownFileEnds" : true, - "requireAuthentication" : false, - "requireAuthorization" : false, - "trustProxy" : false, - "disableIPlogging" : false, - "automaticReconnectionTimeout" : 0, - "scrollWhenFocusLineIsOutOfViewport": { - "percentage": { - "editionAboveViewport": 0, - "editionBelowViewport": 0 + "ip": "127.0.0.1", + "port" : ${env.listenPort}, + "showSettingsInAdminPage" : false, + "dbType" : "postgres", + "dbSettings" : { + "user" : "${env.postgresql.user}", + "host" : "${env.postgresql.socket}", + "password": "${env.postgresql.password}", + "database": "${env.postgresql.database}", + "charset" : "utf8mb4" }, - "duration": 0, - "scrollWhenCaretIsInTheLastLineOfViewport": false, - "percentageToScrollWhenUserPressesArrowUp": 0 - }, - "users": { - "ldapauth": { - "url": "ldaps://${env.ldap.host}", - "accountBase": "${env.ldap.base}", - "accountPattern": "(&(memberOf=cn=users,cn=etherpad,ou=services,dc=immae,dc=eu)(uid={{username}}))", - "displayNameAttribute": "cn", - "searchDN": "cn=etherpad,ou=services,dc=immae,dc=eu", - "searchPWD": "${env.ldap.password}", - "groupSearchBase": "${env.ldap.base}", - "groupAttribute": "member", - "groupAttributeIsDN": true, - "searchScope": "sub", - "groupSearch": "(memberOf=cn=groups,cn=etherpad,ou=services,dc=immae,dc=eu)", - "anonymousReadonly": false - } - }, - "socketTransportProtocols" : ["xhr-polling", "jsonp-polling", "htmlfile"], - "loadTest": false, - "indentationOnNewLine": false, - "toolbar": { - "left": [ - ["bold", "italic", "underline", "strikethrough"], - ["orderedlist", "unorderedlist", "indent", "outdent"], - ["undo", "redo"], - ["clearauthorship"] - ], - "right": [ - ["importexport", "timeslider", "savedrevision"], - ["settings", "embed"], - ["showusers"] - ], - "timeslider": [ - ["timeslider_export", "timeslider_returnToPad"] - ] - }, - "loglevel": "INFO", - "logconfig" : { "appenders": [ { "type": "console" } ] } - } - ''; - }; - webappDir = stdenv.mkDerivation (fetchedGithub ./etherpad-lite.json // rec { - __noChroot = true; - patches = [ ./libreoffice_patch.diff ]; - buildPhase = '' - 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 - - touch src/.ep_initialized - cp -v src/static/custom/js.template src/static/custom/index.js - cp -v src/static/custom/js.template src/static/custom/pad.js - cp -v src/static/custom/js.template src/static/custom/timeslider.js - cp -v src/static/custom/css.template src/static/custom/index.css - cp -v src/static/custom/css.template src/static/custom/pad.css - cp -v src/static/custom/css.template src/static/custom/timeslider.css - - sed -i 's/var\/dirty.db/\/var\/lib\/etherpad-lite\/dirty.db/g' \ - settings.json.template - - mkdir -v node_modules - ln -s ../src node_modules/ep_etherpad-lite - node bin/doc/generate doc/index.md --format=html \ - --template=doc/template.html > documentation.html - - cd src - npm install - cd .. - ${builtins.concatStringsSep "\n" - (map (n: "npm install ${n}; touch node_modules/${n}/.ep_initialized") etherpad_modules)} - ''; - installPhase = '' - mkdir -p $out - install -t $out/src/ -vDm 644 src/.ep_initialized - cp -a node_modules $out/ - cp -a src/* $out/src/ - ln -sf ${sessionkey} $out/SESSIONKEY.txt - ln -sf ${apikey} $out/APIKEY.txt - cp ${jquery} $out/src/static/js/jquery.js + "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", + "padOptions": { + "noColors": false, + "showControls": true, + "showChat": true, + "showLineNumbers": true, + "useMonospaceFont": false, + "userName": false, + "userColor": false, + "rtl": false, + "alwaysShowChat": false, + "chatAndUsers": false, + "lang": "en-gb" + }, - mkdir $out/doc - install -t "$out/doc/" \ - -vDm 644 {CHANGELOG,CONTRIBUTING,README}.md \ - -vDm 644 documentation.html - ''; - buildInputs = [ pkgs.nodejs pkgs.python ]; - }); + "suppressErrorsInPadText" : false, + "requireSession" : false, + "editOnly" : false, + "sessionNoPassword" : false, + "minify" : true, + "maxAge" : 21600, + "abiword" : null, + "soffice" : "${libreoffice}/bin/soffice", + "tidyHtml" : "${pkgs.html-tidy}/bin/tidy", + "allowUnknownFileEnds" : true, + "requireAuthentication" : false, + "requireAuthorization" : false, + "trustProxy" : false, + "disableIPlogging" : false, + "automaticReconnectionTimeout" : 0, + "scrollWhenFocusLineIsOutOfViewport": { + "percentage": { + "editionAboveViewport": 0, + "editionBelowViewport": 0 + }, + "duration": 0, + "scrollWhenCaretIsInTheLastLineOfViewport": false, + "percentageToScrollWhenUserPressesArrowUp": 0 + }, + "users": { + "ldapauth": { + "url": "ldaps://${env.ldap.host}", + "accountBase": "${env.ldap.base}", + "accountPattern": "(&(memberOf=cn=users,cn=etherpad,ou=services,dc=immae,dc=eu)(uid={{username}}))", + "displayNameAttribute": "cn", + "searchDN": "cn=etherpad,ou=services,dc=immae,dc=eu", + "searchPWD": "${env.ldap.password}", + "groupSearchBase": "${env.ldap.base}", + "groupAttribute": "member", + "groupAttributeIsDN": true, + "searchScope": "sub", + "groupSearch": "(memberOf=cn=groups,cn=etherpad,ou=services,dc=immae,dc=eu)", + "anonymousReadonly": false + } + }, + "socketTransportProtocols" : ["xhr-polling", "jsonp-polling", "htmlfile"], + "loadTest": false, + "indentationOnNewLine": false, + "toolbar": { + "left": [ + ["bold", "italic", "underline", "strikethrough"], + ["orderedlist", "unorderedlist", "indent", "outdent"], + ["undo", "redo"], + ["clearauthorship"] + ], + "right": [ + ["importexport", "timeslider", "savedrevision"], + ["settings", "embed"], + ["showusers"] + ], + "timeslider": [ + ["timeslider_export", "timeslider_returnToPad"] + ] + }, + "loglevel": "INFO", + "logconfig" : { "appenders": [ { "type": "console" } ] } + } + ''; + } + ]; + webappDir = (etherpad-lite.override { + session_key = "/var/secrets/webapps/tools-etherpad-sessionkey"; + api_key = "/var/secrets/webapps/tools-etherpad-apikey"; + }).withModules etherpad-lite-modules; in { inherit webappDir keys listenPort;