]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - nixops/modules/websites/tools/ether/etherpad_lite.nix
Make etherpad derivation pure
[perso/Immae/Config/Nix.git] / nixops / modules / websites / tools / ether / etherpad_lite.nix
index 689156e872f84fc057559a636f1a467ff92e5e65..c6f3704c5f4fa324d5dfa5584287cb9adc5d01d3 100644 (file)
@@ -1,53 +1,26 @@
-{ 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-apikey = {
-      destDir = "/run/keys/webapps";
+  keys = [
+    {
+      dest = "webapps/tools-etherpad-apikey";
       permissions = "0400";
       text = env.api_key;
-    };
-    tools-etherpad-sessionkey = {
-      destDir = "/run/keys/webapps";
+    }
+    {
+      dest = "webapps/tools-etherpad-sessionkey";
       permissions = "0400";
       text = env.session_key;
-    };
-    tools-etherpad = {
-      destDir = "/run/keys/webapps";
+    }
+    {
+      dest = "webapps/tools-etherpad";
       permissions = "0400";
       text =
         # Make sure we’re not rebuilding whole libreoffice just because of a
         # dependency
-        let libreoffice = (import <nixpkgs> {}).libreoffice-fresh;
+        let libreoffice = (import <nixpkgs> { overlays = []; }).libreoffice-fresh;
         in
         ''
           {
@@ -144,55 +117,9 @@ let
             "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 /run/keys/webapps/tools-etherpad-sessionkey $out/SESSIONKEY.txt
-      ln -sf /run/keys/webapps/tools-etherpad-apikey $out/APIKEY.txt
-      cp ${jquery} $out/src/static/js/jquery.js
-
-      mkdir $out/doc
-      install -t "$out/doc/" \
-        -vDm 644 {CHANGELOG,CONTRIBUTING,README}.md \
-        -vDm 644 documentation.html
-    '';
-    buildInputs = [ pkgs.nodejs pkgs.python ];
-  });
+    }
+  ];
+  webappDir = etherpad-lite.withModules (builtins.attrValues etherpad-lite-modules);
 in
   {
     inherit webappDir keys listenPort;