@@ -1,20 +1,42 @@
1−{ stdenv, fetchurl, pkgconfig, lua5_2, file, ncurses, gmime, pcre-cpp
2−, perl, perlPackages }:
1+{ stdenv, fetchurl, pkgconfig, lua, file, ncurses, gmime, pcre-cpp
2+, perl, perlPackages, makeWrapper
3+, debugBuild ? false
4+, alternativeGlobalConfigFilePath ? null
5+}:
36
47let
5− version = "2.9";
8+ version = "3.1";
9+ binaryName = if debugBuild then "lumail2-debug" else "lumail2";
10+ alternativeConfig = builtins.toFile "lumail2.lua"
11+ (builtins.readFile alternativeGlobalConfigFilePath);
12+
13+ globalConfig = if isNull alternativeGlobalConfigFilePath then ''
14+ mkdir -p $out/etc/lumail2
15+ cp global.config.lua $out/etc/lumail2.lua
16+ for n in ./lib/*.lua; do
17+ cp "$n" $out/etc/lumail2/
18+ done
19+ '' else ''
20+ ln -s ${alternativeConfig} $out/etc/lumail2.lua
21+ '';
22+
23+ getPath = type : "${lua}/lib/?.${type};";
24+ luaPath = getPath "lua";
25+ luaCPath = getPath "so";
626in
727stdenv.mkDerivation {
828 name = "lumail-${version}";
929
1030 src = fetchurl {
1131 url = "https://lumail.org/download/lumail-${version}.tar.gz";
12− sha256 = "1rni5lbic36v4cd1r0l28542x0hlmfqkl6nac79gln491in2l2sc";
32+ sha256 = "0vj7p7f02m3w8wb74ilajcwznc4ai4h2ikkz9ildy0c00aqsi5w4";
1333 };
1434
15− nativeBuildInputs = [ pkgconfig ];
35+ enableParallelBuilding = true;
36+
37+ nativeBuildInputs = [ pkgconfig makeWrapper ];
1638 buildInputs = [
17− lua5_2 file ncurses gmime pcre-cpp
39+ lua file ncurses gmime pcre-cpp
1840 perl perlPackages.JSON perlPackages.NetIMAPClient
1941 ];
2042
@@ -29,16 +51,26 @@ stdenv.mkDerivation {
2951 sed -e "s|^#\!\(.*/perl.*\)$|#\!\1$perlFlags|" -i perl.d/imap-proxy
3052 '';
3153
54+ buildFlags = if debugBuild then "lumail2-debug" else "";
55+
56+ installPhase = ''
57+ mkdir -p $out/bin || true
58+ install -m755 ${binaryName} $out/bin/
59+ ''
60+ + globalConfig
61+ + ''
62+ wrapProgram $out/bin/${binaryName} \
63+ --prefix LUA_PATH : "${luaPath}" \
64+ --prefix LUA_CPATH : "${luaCPath}"
65+ '';
66+
3267 makeFlags = [
3368 "LVER=lua"
3469 "PREFIX=$(out)"
3570 "SYSCONFDIR=$(out)/etc"
71+ "LUMAIL_LIBS=$(out)/etc/lumail2"
3672 ];
3773
38− postInstall = ''
39− cp lumail2.user.lua $out/etc/lumail2/
40− '';
41−
4274 meta = with stdenv.lib; {
4375 description = "Console-based email client";
4476 homepage = https://lumail.org/;