diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2020-05-04 00:12:46 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2020-05-04 00:12:46 +0200 |
commit | 4b0a82cc2f4597a11b9275cf156ae9cceffaf44f (patch) | |
tree | a384ea0b7a610387f9a9cb8b6de4de58e8dd76b0 /pkgs/webapps/etherpad-lite/default.nix | |
parent | e9c91c19475ed679676829bfd716e41009b560c8 (diff) | |
download | Nix-4b0a82cc2f4597a11b9275cf156ae9cceffaf44f.tar.gz Nix-4b0a82cc2f4597a11b9275cf156ae9cceffaf44f.tar.zst Nix-4b0a82cc2f4597a11b9275cf156ae9cceffaf44f.zip |
Fix some etherpad-lite modules and packaging
The upgrade to 1.8.3 broke many modules, which were patched to continue
working correctly.
This commit also reworks the module system, making it similar to
python’s withPackages.
Diffstat (limited to 'pkgs/webapps/etherpad-lite/default.nix')
-rw-r--r-- | pkgs/webapps/etherpad-lite/default.nix | 62 |
1 files changed, 35 insertions, 27 deletions
diff --git a/pkgs/webapps/etherpad-lite/default.nix b/pkgs/webapps/etherpad-lite/default.nix index 5cd1cfb..4327384 100644 --- a/pkgs/webapps/etherpad-lite/default.nix +++ b/pkgs/webapps/etherpad-lite/default.nix | |||
@@ -1,31 +1,43 @@ | |||
1 | { varDir ? "/var/lib/etherpad-lite" # if you override this change the StateDirectory in service file too! | 1 | { varDir ? "/var/lib/etherpad-lite" # if you override this change the StateDirectory in service file too! |
2 | , stdenv, callPackage, mylibs, fetchurl }: | 2 | , stdenv, callPackage, mylibs, lib }: |
3 | let | 3 | let |
4 | jquery = fetchurl { | 4 | nodeEnv = callPackage mylibs.nodeEnv {}; |
5 | url = https://code.jquery.com/jquery-1.9.1.js; | 5 | moduleNames = [ |
6 | sha256 = "0h4dk67yc9d0kadqxb6b33585f3x3559p6qmp70l00qwq030vn3v"; | 6 | "ep_aa_file_menu_toolbar" "ep_adminpads" "ep_align" "ep_bookmark" |
7 | "ep_clear_formatting" "ep_colors" "ep_comments_page" | ||
8 | "ep_copy_paste_select_all" "ep_cursortrace" "ep_delete_empty_pads" | ||
9 | "ep_embedmedia" "ep_font_family" "ep_font_size" "ep_headings2" | ||
10 | "ep_immae_buttons" "ep_ldapauth" "ep_line_height" "ep_markdown" | ||
11 | "ep_mypads" "ep_page_view" "ep_previewimages" "ep_ruler" | ||
12 | "ep_scrollto" "ep_set_title_on_pad" "ep_subscript_and_superscript" | ||
13 | "ep_timesliderdiff" | ||
14 | ]; | ||
15 | # nix files are built using node2nix -i node-packages.json | ||
16 | allModules = lib.attrsets.genAttrs moduleNames | ||
17 | (name: (callPackage (./modules + "/${name}/node-packages.nix") { inherit nodeEnv; }).${name}); | ||
18 | toPassthru = pkg: { | ||
19 | inherit varDir allModules; | ||
20 | withModules = withModules pkg; | ||
7 | }; | 21 | }; |
8 | withModules = modules: package.overrideAttrs(old: { | 22 | withModules = pkg: toModules: |
9 | installPhase = let | 23 | let |
10 | modInst = n: | 24 | modules = toModules allModules; |
11 | let n' = n.override { | 25 | toInstallModule = n: '' |
12 | postInstall = '' | 26 | cp -a ${n}/lib/node_modules/${n.packageName} $out/node_modules |
13 | if [ ! -f $out/lib/node_modules/${n.moduleName}/.ep_initialized ]; then | 27 | if [ ! -f $out/node_modules/${n.packageName}/.ep_initialized ]; then |
14 | ln -s ${varDir}/ep_initialized/${n.moduleName} $out/lib/node_modules/${n.moduleName}/.ep_initialized | 28 | chmod u+w $out/node_modules/${n.packageName}/ |
15 | fi | 29 | ln -s ${varDir}/ep_initialized/${n.packageName} $out/node_modules/${n.packageName}/.ep_initialized |
16 | ''; | 30 | fi |
17 | }; | 31 | ''; |
18 | in "cp -a ${n'}/lib/node_modules/${n.moduleName} $out/node_modules"; | 32 | newEtherpad = pkg.overrideAttrs(old: { |
19 | in old.installPhase + builtins.concatStringsSep "\n" (map modInst modules); | 33 | installPhase = old.installPhase + "\n" + builtins.concatStringsSep "\n" (map toInstallModule modules); |
20 | passthru = old.passthru // { | 34 | passthru = toPassthru newEtherpad; |
21 | inherit modules; | 35 | }); |
22 | withModules = moreModules: old.withModules (moreModules ++ modules); | 36 | in newEtherpad; |
23 | }; | ||
24 | }); | ||
25 | # built using node2nix -l package-lock.json | 37 | # built using node2nix -l package-lock.json |
26 | # and changing "./." to "src" | 38 | # and changing "./." to "src" |
27 | node-environment = (callPackage ./node-packages.nix { | 39 | node-environment = (callPackage ./node-packages.nix { |
28 | nodeEnv = callPackage mylibs.nodeEnv {}; | 40 | inherit nodeEnv; |
29 | src = stdenv.mkDerivation (mylibs.fetchedGithub ./etherpad-lite.json // rec { | 41 | src = stdenv.mkDerivation (mylibs.fetchedGithub ./etherpad-lite.json // rec { |
30 | patches = [ ./libreoffice_patch.diff ]; | 42 | patches = [ ./libreoffice_patch.diff ]; |
31 | buildPhase = '' | 43 | buildPhase = '' |
@@ -44,12 +56,8 @@ let | |||
44 | mkdir $out/node_modules | 56 | mkdir $out/node_modules |
45 | cp -a lib/node_modules/ep_etherpad-lite $out/src | 57 | cp -a lib/node_modules/ep_etherpad-lite $out/src |
46 | chmod u+w $out/src/static/js/ | 58 | 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 | 59 | ln -s ../src $out/node_modules/ep_etherpad-lite |
49 | ''; | 60 | ''; |
50 | passthru = { | 61 | passthru = toPassthru package; |
51 | modules = []; | ||
52 | inherit varDir withModules; | ||
53 | }; | ||
54 | }; | 62 | }; |
55 | in package | 63 | in package |