anchor.diff:      sed -e "s|^#\!\(.*/perl.*\)$|#\!\1$perlFlags|" -i perl.d/imap-proxy
     '';
   
  +  buildFlags = if debugBuild then "lumail2-debug" else "";
  +
  +  installPhase = ''
  +    mkdir -p $out/bin || true
  +    install -m755 ${binaryName} $out/bin/
  +  ''
  +  + globalConfig
  +  + ''
  +    wrapProgram $out/bin/${binaryName} \
  +        --prefix LUA_PATH : "${luaPath}" \
  +        --prefix LUA_CPATH : "${luaCPath}"
  +  '';
  +
     makeFlags = [
       "LVER=lua"
       "PREFIX=$(out)"
       "SYSCONFDIR=$(out)/etc"
  +    "LUMAIL_LIBS=$(out)/etc/lumail2"
     ];
  -
  -  postInstall = ''
  -    cp lumail2.user.lua $out/etc/lumail2/
  -  '';
   
     meta = with stdenv.lib; {
       description = "Console-based email client";
  
positive.code:     sha256 = "0vj7p7f02m3w8wb74ilajcwznc4ai4h2ikkz9ildy0c00aqsi5w4";
    };
  
    nativeBuildInputs = [ pkgconfig ];
    buildInputs = [
      lua5_2 file ncurses gmime pcre-cpp
      perl perlPackages.JSON perlPackages.NetIMAPClient
  
negative.code: { stdenv, fetchurl, pkgconfig, lua5_2, file, ncurses, gmime, pcre-cpp
  , perl, perlPackages
  , debugBuild ? false
  , alternativeGlobalConfigFilePath ? null
  }:
  
  let
    version    = "3.1";
    binaryName = if debugBuild then "lumail2-debug" else "lumail2";
    alternativeConfig = builtins.toFile "lumail2.lua"
      (builtins.readFile alternativeGlobalConfigFilePath);
  
    globalConfig = if isNull alternativeGlobalConfigFilePath then ''
      mkdir -p $out/etc/lumail2
      cp global.config.lua $out/etc/lumail2.lua
      for n in ./lib/*.lua; do
        cp "$n" $out/etc/lumail2/
      done
    '' else ''
      ln -s ${alternativeConfig} $out/etc/lumail2.lua
    '';
  
    getPath  = type : "${lua}/lib/?.${type};";
    luaPath  = getPath "lua";
    luaCPath = getPath "so";
  in
  stdenv.mkDerivation {
    name = "lumail-${version}";
  