]> git.immae.eu Git - perso/Immae/Config/Nix.git/commitdiff
Move etherpad-lite to pkgs
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Wed, 8 May 2019 08:56:21 +0000 (10:56 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Wed, 8 May 2019 08:56:21 +0000 (10:56 +0200)
nixops/modules/websites/tools/ether/default.nix
nixops/modules/websites/tools/ether/etherpad_lite.nix
pkgs/impure/etherpad-lite/default.nix [new file with mode: 0644]
pkgs/impure/etherpad-lite/etherpad-lite.json [moved from nixops/modules/websites/tools/ether/etherpad-lite.json with 100% similarity]
pkgs/impure/etherpad-lite/libreoffice_patch.diff [moved from nixops/modules/websites/tools/ether/libreoffice_patch.diff with 100% similarity]
pkgs/webapps/default.nix

index 0d04c36dc26f2a42014aa1a9f2127b0752d5434e..09e5c9daffdf08b0cd1272e65de8b641158f0a04 100644 (file)
@@ -1,7 +1,7 @@
 { lib, pkgs, config, myconfig, mylibs, ... }:
 let
   etherpad = pkgs.callPackage ./etherpad_lite.nix {
-    inherit (mylibs) fetchedGithub;
+    inherit (pkgs.webapps) etherpad-lite etherpad-lite-modules;
     env = myconfig.env.tools.etherpad-lite;
   };
 
@@ -44,7 +44,7 @@ in {
         Restart = "always";
         Type = "simple";
         TimeoutSec = 60;
-        ExecStartPre = "+${pkgs.coreutils}/bin/chown etherpad-lite:etherpad-lite /var/secrets/webapps/tools-etherpad /var/secrets/webapps/tools-etherpad-sessionkey /var/secrets/webapps/tools-etherpad-apikey";
+        ExecStartPre = "+${pkgs.coreutils}/bin/chown -R etherpad-lite:etherpad-lite /var/secrets/webapps/tools-etherpad /var/secrets/webapps/tools-etherpad-sessionkey /var/secrets/webapps/tools-etherpad-apikey";
       };
     };
 
index e67497be8e023442c8e2f4b879cfa23573289ab3..35220eee210e3ae67674dcfc748c51992ee9409a 100644 (file)
@@ -1,35 +1,8 @@
-{ 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 = [
     {
       dest = "webapps/tools-etherpad-apikey";
@@ -146,53 +119,10 @@ let
         '';
     }
   ];
-  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 /var/secrets/webapps/tools-etherpad-sessionkey $out/SESSIONKEY.txt
-      ln -sf /var/secrets/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.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;
diff --git a/pkgs/impure/etherpad-lite/default.nix b/pkgs/impure/etherpad-lite/default.nix
new file mode 100644 (file)
index 0000000..c85bd7e
--- /dev/null
@@ -0,0 +1,69 @@
+{ session_key ? "/etc/etherpad-lite/SESSIONKEY.txt"
+, api_key ? "/etc/etherpad-lite/APIKEY.txt"
+, stdenv, mylibs, cacert, nodejs, python, fetchurl }:
+let
+  jquery = fetchurl {
+    url = https://code.jquery.com/jquery-1.9.1.js;
+    sha256 = "0h4dk67yc9d0kadqxb6b33585f3x3559p6qmp70l00qwq030vn3v";
+  };
+  withModules = modules: package.overrideAttrs(old: {
+    buildPhase = old.buildPhase +
+      builtins.concatStringsSep "\n"
+        (map (n: "npm install ${n}; touch node_modules/${n}/.ep_initialized") modules);
+    # FIXME: ln -s don’t seem to work, etherpad seems
+    # unable to "touch" them after initialization
+    passthru = old.passthru // {
+      inherit modules;
+      withModules = moreModules: old.withModules (moreModules ++ modules);
+    };
+  });
+  package = stdenv.mkDerivation (mylibs.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 ..
+      '';
+    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 ${session_key} $out/SESSIONKEY.txt
+      ln -sf ${api_key} $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 = [ nodejs python ];
+    passthru = {
+      modules = [];
+      inherit withModules;
+    };
+  });
+in package
index 8fbb20f1ef645eb743fa2ee47efe5bc859e74e73..a771aeeb9e41bed090b5fab34dec25b96f6805f4 100644 (file)
@@ -13,6 +13,32 @@ rec {
     lib.attrsets.genAttrs names
       (name: callPackage (./dokuwiki/plugins + "/${name}.nix") {});
 
+  etherpad-lite = callPackage ../impure/etherpad-lite {};
+  etherpad-lite-with-modules = etherpad-lite.withModules etherpad-lite-modules;
+  etherpad-lite-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"
+    ];
+
   infcloud = callPackage ./infcloud {};
 
   mantisbt_2 = callPackage ./mantisbt_2 {};