]> git.immae.eu Git - perso/Immae/Config/Nix/NUR.git/blame - pkgs/webapps/etherpad-lite/default.nix
Initial commit published for NUR
[perso/Immae/Config/Nix/NUR.git] / pkgs / webapps / etherpad-lite / default.nix
CommitLineData
24fd1fe6
IB
1{ varDir ? "/var/lib/etherpad-lite" # if you override this change the StateDirectory in service file too!
2, stdenv, callPackage, mylibs, fetchurl }:
3let
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 cp -v src/static/custom/js.template src/static/custom/index.js
34 cp -v src/static/custom/js.template src/static/custom/pad.js
35 cp -v src/static/custom/js.template src/static/custom/timeslider.js
36 cp -v src/static/custom/css.template src/static/custom/index.css
37 cp -v src/static/custom/css.template src/static/custom/pad.css
38 cp -v src/static/custom/css.template src/static/custom/timeslider.css
39 '';
40 installPhase = ''
41 cp -a src/ $out
42 '';
43 });
44 }).package;
45 package = stdenv.mkDerivation rec {
46 name = (mylibs.fetchedGithub ./etherpad-lite.json).name;
47 src = node-environment;
48 installPhase = ''
49 mkdir -p $out
50 mkdir $out/node_modules
51 cp -a lib/node_modules/ep_etherpad-lite $out/src
52 chmod u+w $out/src/static/js/
53 cp ${jquery} $out/src/static/js/jquery.js
54 ln -s ../src $out/node_modules/ep_etherpad-lite
55 '';
56 passthru = {
57 modules = [];
58 inherit varDir withModules;
59 };
60 };
61in package