aboutsummaryrefslogtreecommitdiff
path: root/pkgs/webapps/roundcubemail/default.nix
blob: 4f288b8882389bd4ed0344b06a226d3ef00f9b57 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
{ varDir ? "/var/lib/roundcubemail"
, roundcube_config ? "/etc/roundcube/config.php"
, stdenv, fetchurl, jre, unzip }:
let
  defaultInstall = ''
    mkdir -p $out
    cp -R . $out/
    cd $out
    if [ -d skins -a -d skins/larry -a ! -d skins/elastic ]; then
      ln -s larry skins/elastic
    fi
    '';
  buildPlugin = { appName, version, url, sha256, installPhase ? defaultInstall }:
    stdenv.mkDerivation rec {
      name = "roundcube-${appName}-${version}";
      inherit version;
      phases = "unpackPhase installPhase";
      inherit installPhase;
      src = fetchurl { inherit url sha256; };
      passthru.pluginName = appName;
    };
  withPlugins = plugins: skins: package.overrideAttrs(old: {
    name = "${old.name}${if builtins.length skins > 0 then "-with-skins" else ""}${if builtins.length plugins > 0 then "-with-plugins" else ""}";
    installPhase = old.installPhase +
      builtins.concatStringsSep "\n" (
        map (value: "ln -s ${value} $out/plugins/${value.pluginName}") plugins
      ) +
      builtins.concatStringsSep "\n" (
        map (value: "ln -s ${value} $out/skins/${value.skinName}") skins
      );
    passthru = old.passthru // {
      inherit plugins skins;
      withPlugins = morePlugins: moreSkins: old.withPlugins (morePlugins ++ plugins) (morePlugins ++ skins);
    };
  });
  shrinker = fetchurl {
    url = "http://dl.google.com/closure-compiler/compiler-latest.zip";
    sha256 = "0naf3kflhlkm17ls1x7mgddd3b01f8yzbbbdjqwy5m12jmkzl2d5";
  };
  package = stdenv.mkDerivation rec {
    version = "1.4.4";
    name = "roundcubemail-${version}";
    src= fetchurl {
      url = "https://github.com/roundcube/roundcubemail/releases/download/${version}/${name}-complete.tar.gz";
      sha256 = "1my726p0wmsn21nbdsjx02h6hnbh8nidzipzdy0gk0qgda1j729b";
    };
    patches = [ ./add_all.patch ]; # This patch includes js modification which requires to re-run the jsshrink below
    buildInputs = [ unzip jre ];
    buildPhase = ''
      mkdir -p /tmp
      unzip -p "${shrinker}" "*.jar" > "/tmp/compiler.jar"
      ./bin/jsshrink.sh
      sed -i \
        -e "s|RCUBE_INSTALL_PATH . 'temp.*|'${varDir}/cache';|" \
        config/defaults.inc.php
      sed -i \
        -e "s|RCUBE_INSTALL_PATH . 'logs.*|'${varDir}/logs';|" \
        config/defaults.inc.php
    '';
    installPhase = ''
      cp -a . $out
      ln -s ${roundcube_config} $out/config/config.inc.php
    '';
    passthru = {
      plugins = [];
      skins = [];
      inherit withPlugins buildPlugin;
    };
  };
in package