]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - pkgs/webapps/etherpad-lite/default.nix
Upgrade etherpad-lite
[perso/Immae/Config/Nix.git] / pkgs / webapps / etherpad-lite / default.nix
1 { varDir ? "/var/lib/etherpad-lite" # if you override this change the StateDirectory in service file too!
2 , stdenv, callPackage, mylibs, fetchurl }:
3 let
4 jquery = fetchurl {
5 url = https://code.jquery.com/jquery-1.9.1.js;
6 sha256 = "0h4dk67yc9d0kadqxb6b33585f3x3559p6qmp70l00qwq030vn3v";
7 };
8 withModules = modules: package.overrideAttrs(old: {
9 installPhase = let
10 modInst = n:
11 let n' = n.override {
12 postInstall = ''
13 if [ ! -f $out/lib/node_modules/${n.moduleName}/.ep_initialized ]; then
14 ln -s ${varDir}/ep_initialized/${n.moduleName} $out/lib/node_modules/${n.moduleName}/.ep_initialized
15 fi
16 '';
17 };
18 in "cp -a ${n'}/lib/node_modules/${n.moduleName} $out/node_modules";
19 in old.installPhase + builtins.concatStringsSep "\n" (map modInst modules);
20 passthru = old.passthru // {
21 inherit modules;
22 withModules = moreModules: old.withModules (moreModules ++ modules);
23 };
24 });
25 # built using node2nix -l package-lock.json
26 # and changing "./." to "src"
27 node-environment = (callPackage ./node-packages.nix {
28 nodeEnv = callPackage mylibs.nodeEnv {};
29 src = stdenv.mkDerivation (mylibs.fetchedGithub ./etherpad-lite.json // rec {
30 patches = [ ./libreoffice_patch.diff ];
31 buildPhase = ''
32 touch src/.ep_initialized
33 '';
34 installPhase = ''
35 cp -a src/ $out
36 '';
37 });
38 }).package;
39 package = stdenv.mkDerivation rec {
40 name = (mylibs.fetchedGithub ./etherpad-lite.json).name;
41 src = node-environment;
42 installPhase = ''
43 mkdir -p $out
44 mkdir $out/node_modules
45 cp -a lib/node_modules/ep_etherpad-lite $out/src
46 chmod u+w $out/src/static/js/
47 #cp ${jquery} $out/src/static/js/jquery.js
48 ln -s ../src $out/node_modules/ep_etherpad-lite
49 '';
50 passthru = {
51 modules = [];
52 inherit varDir withModules;
53 };
54 };
55 in package