]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - pkgs/impure/etherpad-lite/default.nix
Move node-env file to a generic location
[perso/Immae/Config/Nix.git] / pkgs / impure / etherpad-lite / default.nix
1 { session_key ? "/etc/etherpad-lite/SESSIONKEY.txt"
2 , api_key ? "/etc/etherpad-lite/APIKEY.txt"
3 , stdenv, mylibs, cacert, nodejs, python, fetchurl }:
4 let
5 jquery = fetchurl {
6 url = https://code.jquery.com/jquery-1.9.1.js;
7 sha256 = "0h4dk67yc9d0kadqxb6b33585f3x3559p6qmp70l00qwq030vn3v";
8 };
9 withModules = modules: package.overrideAttrs(old: {
10 buildPhase = old.buildPhase +
11 builtins.concatStringsSep "\n"
12 (map (n: "npm install ${n}; touch node_modules/${n}/.ep_initialized") modules);
13 # FIXME: ln -s don’t seem to work, etherpad seems
14 # unable to "touch" them after initialization
15 passthru = old.passthru // {
16 inherit modules;
17 withModules = moreModules: old.withModules (moreModules ++ modules);
18 };
19 });
20 package = stdenv.mkDerivation (mylibs.fetchedGithub ./etherpad-lite.json // rec {
21 __noChroot = true;
22 patches = [ ./libreoffice_patch.diff ];
23 buildPhase = ''
24 export GIT_SSL_CAINFO=${cacert}/etc/ssl/certs/ca-bundle.crt
25 export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt
26 export HOME=$PWD
27
28 touch src/.ep_initialized
29 cp -v src/static/custom/js.template src/static/custom/index.js
30 cp -v src/static/custom/js.template src/static/custom/pad.js
31 cp -v src/static/custom/js.template src/static/custom/timeslider.js
32 cp -v src/static/custom/css.template src/static/custom/index.css
33 cp -v src/static/custom/css.template src/static/custom/pad.css
34 cp -v src/static/custom/css.template src/static/custom/timeslider.css
35
36 sed -i 's/var\/dirty.db/\/var\/lib\/etherpad-lite\/dirty.db/g' \
37 settings.json.template
38
39 mkdir -v node_modules
40 ln -s ../src node_modules/ep_etherpad-lite
41
42 node bin/doc/generate doc/index.md --format=html \
43 --template=doc/template.html > documentation.html
44
45 cd src
46 npm install
47 cd ..
48 '';
49 installPhase = ''
50 mkdir -p $out
51 install -t $out/src/ -vDm 644 src/.ep_initialized
52 cp -a node_modules $out/
53 cp -a src/* $out/src/
54 ln -sf ${session_key} $out/SESSIONKEY.txt
55 ln -sf ${api_key} $out/APIKEY.txt
56 cp ${jquery} $out/src/static/js/jquery.js
57
58 mkdir $out/doc
59 install -t "$out/doc/" \
60 -vDm 644 {CHANGELOG,CONTRIBUTING,README}.md \
61 -vDm 644 documentation.html
62 '';
63 buildInputs = [ nodejs python ];
64 passthru = {
65 modules = [];
66 inherit withModules;
67 };
68 });
69 in package