aboutsummaryrefslogtreecommitdiff
path: root/flakes/etherpad-lite/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'flakes/etherpad-lite/default.nix')
-rw-r--r--flakes/etherpad-lite/default.nix68
1 files changed, 68 insertions, 0 deletions
diff --git a/flakes/etherpad-lite/default.nix b/flakes/etherpad-lite/default.nix
new file mode 100644
index 0000000..1dd5aa4
--- /dev/null
+++ b/flakes/etherpad-lite/default.nix
@@ -0,0 +1,68 @@
1{ varDir ? "/var/lib/etherpad-lite" # if you override this change the StateDirectory in service file too!
2, nodeEnv, stdenv, callPackage, src, lib, nodejs }:
3let
4 moduleNames = [
5 "ep_aa_file_menu_toolbar" "ep_adminpads" "ep_align" "ep_bookmark"
6 "ep_clear_formatting" "ep_colors" "ep_comments_page"
7 "ep_copy_paste_select_all" "ep_cursortrace" "ep_delete_empty_pads"
8 "ep_embedmedia" "ep_font_family" "ep_font_size" "ep_headings2"
9 "ep_immae_buttons" "ep_ldapauth" "ep_line_height" "ep_markdown"
10 "ep_mypads" "ep_page_view" "ep_previewimages" "ep_ruler"
11 "ep_scrollto" "ep_set_title_on_pad" "ep_subscript_and_superscript"
12 "ep_timesliderdiff"
13 ];
14 # nix files are built using node2nix -i node-packages.json
15 allModules = lib.attrsets.genAttrs moduleNames
16 (name: (callPackage (./modules + "/${name}/node-packages.nix") { nodeEnv = callPackage nodeEnv {}; }).${name});
17 toPassthru = pkg: moduleNames: {
18 inherit varDir allModules nodejs moduleNames;
19 withModules = withModules pkg;
20 };
21 withModules = pkg: toModules:
22 let
23 modules = toModules allModules;
24 toInstallModule = n: ''
25 cp -a ${n}/lib/node_modules/${n.packageName} $out/node_modules
26 if [ ! -f $out/node_modules/${n.packageName}/.ep_initialized ]; then
27 chmod u+w $out/node_modules/${n.packageName}/
28 ln -s ${varDir}/ep_initialized/${n.packageName} $out/node_modules/${n.packageName}/.ep_initialized
29 fi
30 '';
31 modulesNames = map (n: n.packageName) modules;
32 newEtherpad = pkg.overrideAttrs(old: {
33 installPhase = old.installPhase + "\n" + builtins.concatStringsSep "\n" (map toInstallModule modules);
34 passthru = toPassthru newEtherpad moduleNames;
35 });
36 in newEtherpad;
37 # built using node2nix -l package-lock.json
38 # and changing "./." to "src"
39 node-environment = (callPackage ./node-packages.nix {
40 nodeEnv = callPackage nodeEnv {};
41 src = stdenv.mkDerivation {
42 pname = "etherpad-lite";
43 version = src.version;
44 inherit src;
45 patches = [ ./libreoffice_patch.diff ];
46 buildPhase = ''
47 touch src/.ep_initialized
48 '';
49 installPhase = ''
50 cp -a src/ $out
51 '';
52 };
53 }).package;
54 package = stdenv.mkDerivation rec {
55 name = "etherpad-lite-${src.version}";
56 src = node-environment;
57 version = src.version;
58 installPhase = ''
59 mkdir -p $out
60 mkdir $out/node_modules
61 cp -a lib/node_modules/ep_etherpad-lite $out/src
62 chmod u+w $out/src/static/js/
63 ln -s ../src $out/node_modules/ep_etherpad-lite
64 ln -s ${varDir}/var $out/var
65 '';
66 passthru = toPassthru package [];
67 };
68in package