diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2019-05-08 10:56:21 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2019-05-08 10:56:21 +0200 |
commit | a8bfce17c5eda890d3486357952572f4c1c6b18a (patch) | |
tree | e7acfe9fa0aa99cb4b54f941bc6742ee897393c6 | |
parent | fd2d83bd2bf20fafc63daf5041db0151a4b4d17d (diff) | |
download | Nix-a8bfce17c5eda890d3486357952572f4c1c6b18a.tar.gz Nix-a8bfce17c5eda890d3486357952572f4c1c6b18a.tar.zst Nix-a8bfce17c5eda890d3486357952572f4c1c6b18a.zip |
Move etherpad-lite to pkgs
-rw-r--r-- | nixops/modules/websites/tools/ether/default.nix | 4 | ||||
-rw-r--r-- | nixops/modules/websites/tools/ether/etherpad_lite.nix | 80 | ||||
-rw-r--r-- | pkgs/impure/etherpad-lite/default.nix | 69 | ||||
-rw-r--r-- | pkgs/impure/etherpad-lite/etherpad-lite.json (renamed from nixops/modules/websites/tools/ether/etherpad-lite.json) | 0 | ||||
-rw-r--r-- | pkgs/impure/etherpad-lite/libreoffice_patch.diff (renamed from nixops/modules/websites/tools/ether/libreoffice_patch.diff) | 0 | ||||
-rw-r--r-- | pkgs/webapps/default.nix | 26 |
6 files changed, 102 insertions, 77 deletions
diff --git a/nixops/modules/websites/tools/ether/default.nix b/nixops/modules/websites/tools/ether/default.nix index 0d04c36..09e5c9d 100644 --- a/nixops/modules/websites/tools/ether/default.nix +++ b/nixops/modules/websites/tools/ether/default.nix | |||
@@ -1,7 +1,7 @@ | |||
1 | { lib, pkgs, config, myconfig, mylibs, ... }: | 1 | { lib, pkgs, config, myconfig, mylibs, ... }: |
2 | let | 2 | let |
3 | etherpad = pkgs.callPackage ./etherpad_lite.nix { | 3 | etherpad = pkgs.callPackage ./etherpad_lite.nix { |
4 | inherit (mylibs) fetchedGithub; | 4 | inherit (pkgs.webapps) etherpad-lite etherpad-lite-modules; |
5 | env = myconfig.env.tools.etherpad-lite; | 5 | env = myconfig.env.tools.etherpad-lite; |
6 | }; | 6 | }; |
7 | 7 | ||
@@ -44,7 +44,7 @@ in { | |||
44 | Restart = "always"; | 44 | Restart = "always"; |
45 | Type = "simple"; | 45 | Type = "simple"; |
46 | TimeoutSec = 60; | 46 | TimeoutSec = 60; |
47 | 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"; | 47 | 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"; |
48 | }; | 48 | }; |
49 | }; | 49 | }; |
50 | 50 | ||
diff --git a/nixops/modules/websites/tools/ether/etherpad_lite.nix b/nixops/modules/websites/tools/ether/etherpad_lite.nix index e67497b..35220ee 100644 --- a/nixops/modules/websites/tools/ether/etherpad_lite.nix +++ b/nixops/modules/websites/tools/ether/etherpad_lite.nix | |||
@@ -1,35 +1,8 @@ | |||
1 | { env, fetchedGithub, fetchurl, stdenv, writeText, pkgs, cacert }: | 1 | { env, etherpad-lite, etherpad-lite-modules, writeText, pkgs }: |
2 | let | 2 | let |
3 | listenPort = env.listenPort; | 3 | listenPort = env.listenPort; |
4 | sessionkey = writeText "SESSIONKEY.txt" env.session_key; | 4 | sessionkey = writeText "SESSIONKEY.txt" env.session_key; |
5 | apikey = writeText "APIKEY.txt" env.api_key; | 5 | apikey = writeText "APIKEY.txt" env.api_key; |
6 | jquery = fetchurl { | ||
7 | url = https://code.jquery.com/jquery-1.9.1.js; | ||
8 | sha256 = "0h4dk67yc9d0kadqxb6b33585f3x3559p6qmp70l00qwq030vn3v"; | ||
9 | }; | ||
10 | etherpad_modules = [ | ||
11 | "ep_aa_file_menu_toolbar" | ||
12 | "ep_adminpads" | ||
13 | "ep_align" | ||
14 | "ep_bookmark" | ||
15 | "ep_clear_formatting" | ||
16 | "ep_colors" | ||
17 | "ep_copy_paste_select_all" | ||
18 | "ep_cursortrace" | ||
19 | "ep_embedmedia" | ||
20 | "ep_font_family" | ||
21 | "ep_font_size" | ||
22 | "ep_headings2" | ||
23 | "ep_ldapauth" | ||
24 | "ep_line_height" | ||
25 | "ep_markdown" | ||
26 | "ep_previewimages" | ||
27 | "ep_ruler" | ||
28 | "ep_scrollto" | ||
29 | "ep_set_title_on_pad" | ||
30 | "ep_subscript_and_superscript" | ||
31 | "ep_timesliderdiff" | ||
32 | ]; | ||
33 | keys = [ | 6 | keys = [ |
34 | { | 7 | { |
35 | dest = "webapps/tools-etherpad-apikey"; | 8 | dest = "webapps/tools-etherpad-apikey"; |
@@ -146,53 +119,10 @@ let | |||
146 | ''; | 119 | ''; |
147 | } | 120 | } |
148 | ]; | 121 | ]; |
149 | webappDir = stdenv.mkDerivation (fetchedGithub ./etherpad-lite.json // rec { | 122 | webappDir = (etherpad-lite.override { |
150 | __noChroot = true; | 123 | session_key = "/var/secrets/webapps/tools-etherpad-sessionkey"; |
151 | patches = [ ./libreoffice_patch.diff ]; | 124 | api_key = "/var/secrets/webapps/tools-etherpad-apikey"; |
152 | buildPhase = '' | 125 | }).withModules etherpad-lite-modules; |
153 | export GIT_SSL_CAINFO=${cacert}/etc/ssl/certs/ca-bundle.crt | ||
154 | export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt | ||
155 | export HOME=$PWD | ||
156 | |||
157 | touch src/.ep_initialized | ||
158 | cp -v src/static/custom/js.template src/static/custom/index.js | ||
159 | cp -v src/static/custom/js.template src/static/custom/pad.js | ||
160 | cp -v src/static/custom/js.template src/static/custom/timeslider.js | ||
161 | cp -v src/static/custom/css.template src/static/custom/index.css | ||
162 | cp -v src/static/custom/css.template src/static/custom/pad.css | ||
163 | cp -v src/static/custom/css.template src/static/custom/timeslider.css | ||
164 | |||
165 | sed -i 's/var\/dirty.db/\/var\/lib\/etherpad-lite\/dirty.db/g' \ | ||
166 | settings.json.template | ||
167 | |||
168 | mkdir -v node_modules | ||
169 | ln -s ../src node_modules/ep_etherpad-lite | ||
170 | |||
171 | node bin/doc/generate doc/index.md --format=html \ | ||
172 | --template=doc/template.html > documentation.html | ||
173 | |||
174 | cd src | ||
175 | npm install | ||
176 | cd .. | ||
177 | ${builtins.concatStringsSep "\n" | ||
178 | (map (n: "npm install ${n}; touch node_modules/${n}/.ep_initialized") etherpad_modules)} | ||
179 | ''; | ||
180 | installPhase = '' | ||
181 | mkdir -p $out | ||
182 | install -t $out/src/ -vDm 644 src/.ep_initialized | ||
183 | cp -a node_modules $out/ | ||
184 | cp -a src/* $out/src/ | ||
185 | ln -sf /var/secrets/webapps/tools-etherpad-sessionkey $out/SESSIONKEY.txt | ||
186 | ln -sf /var/secrets/webapps/tools-etherpad-apikey $out/APIKEY.txt | ||
187 | cp ${jquery} $out/src/static/js/jquery.js | ||
188 | |||
189 | mkdir $out/doc | ||
190 | install -t "$out/doc/" \ | ||
191 | -vDm 644 {CHANGELOG,CONTRIBUTING,README}.md \ | ||
192 | -vDm 644 documentation.html | ||
193 | ''; | ||
194 | buildInputs = [ pkgs.nodejs pkgs.python ]; | ||
195 | }); | ||
196 | in | 126 | in |
197 | { | 127 | { |
198 | inherit webappDir keys listenPort; | 128 | inherit webappDir keys listenPort; |
diff --git a/pkgs/impure/etherpad-lite/default.nix b/pkgs/impure/etherpad-lite/default.nix new file mode 100644 index 0000000..c85bd7e --- /dev/null +++ b/pkgs/impure/etherpad-lite/default.nix | |||
@@ -0,0 +1,69 @@ | |||
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 | ||
diff --git a/nixops/modules/websites/tools/ether/etherpad-lite.json b/pkgs/impure/etherpad-lite/etherpad-lite.json index 81369c4..81369c4 100644 --- a/nixops/modules/websites/tools/ether/etherpad-lite.json +++ b/pkgs/impure/etherpad-lite/etherpad-lite.json | |||
diff --git a/nixops/modules/websites/tools/ether/libreoffice_patch.diff b/pkgs/impure/etherpad-lite/libreoffice_patch.diff index d9e3dfc..d9e3dfc 100644 --- a/nixops/modules/websites/tools/ether/libreoffice_patch.diff +++ b/pkgs/impure/etherpad-lite/libreoffice_patch.diff | |||
diff --git a/pkgs/webapps/default.nix b/pkgs/webapps/default.nix index 8fbb20f..a771aee 100644 --- a/pkgs/webapps/default.nix +++ b/pkgs/webapps/default.nix | |||
@@ -13,6 +13,32 @@ rec { | |||
13 | lib.attrsets.genAttrs names | 13 | lib.attrsets.genAttrs names |
14 | (name: callPackage (./dokuwiki/plugins + "/${name}.nix") {}); | 14 | (name: callPackage (./dokuwiki/plugins + "/${name}.nix") {}); |
15 | 15 | ||
16 | etherpad-lite = callPackage ../impure/etherpad-lite {}; | ||
17 | etherpad-lite-with-modules = etherpad-lite.withModules etherpad-lite-modules; | ||
18 | etherpad-lite-modules = [ | ||
19 | "ep_aa_file_menu_toolbar" | ||
20 | "ep_adminpads" | ||
21 | "ep_align" | ||
22 | "ep_bookmark" | ||
23 | "ep_clear_formatting" | ||
24 | "ep_colors" | ||
25 | "ep_copy_paste_select_all" | ||
26 | "ep_cursortrace" | ||
27 | "ep_embedmedia" | ||
28 | "ep_font_family" | ||
29 | "ep_font_size" | ||
30 | "ep_headings2" | ||
31 | "ep_ldapauth" | ||
32 | "ep_line_height" | ||
33 | "ep_markdown" | ||
34 | "ep_previewimages" | ||
35 | "ep_ruler" | ||
36 | "ep_scrollto" | ||
37 | "ep_set_title_on_pad" | ||
38 | "ep_subscript_and_superscript" | ||
39 | "ep_timesliderdiff" | ||
40 | ]; | ||
41 | |||
16 | infcloud = callPackage ./infcloud {}; | 42 | infcloud = callPackage ./infcloud {}; |
17 | 43 | ||
18 | mantisbt_2 = callPackage ./mantisbt_2 {}; | 44 | mantisbt_2 = callPackage ./mantisbt_2 {}; |