2018-07-21 01:44:44 +01:00
|
|
|
{ luarocks, lib , stdenv, readline, makeWrapper,
|
|
|
|
less, ncurses, cmake, coreutils, fetchgit, libuuid, czmq, openssl,
|
|
|
|
gnuplot, lua, src, libjpeg, libpng
|
2016-03-14 09:32:48 +00:00
|
|
|
} :
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
common_meta = {
|
|
|
|
homepage = http://torch.ch;
|
|
|
|
license = stdenv.lib.licenses.bsd3;
|
|
|
|
maintainers = with stdenv.lib.maintainers; [ smironov ];
|
2018-04-30 23:47:47 +01:00
|
|
|
platforms = stdenv.lib.platforms.gnu ++ stdenv.lib.platforms.linux;
|
2016-03-14 09:32:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
distro_src = src;
|
|
|
|
|
|
|
|
default_luarocks = luarocks;
|
|
|
|
|
|
|
|
pkgs_gnuplot = gnuplot;
|
|
|
|
|
|
|
|
luapkgs = rec {
|
|
|
|
|
|
|
|
luarocks = default_luarocks.override {
|
2016-03-21 09:51:20 +00:00
|
|
|
inherit lua;
|
2016-03-14 09:32:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
buildLuaRocks = { rockspec ? "", luadeps ? [] , buildInputs ? []
|
|
|
|
, preBuild ? "" , postInstall ? ""
|
|
|
|
, runtimeDeps ? [] , ... }@args :
|
|
|
|
let
|
|
|
|
|
|
|
|
luadeps_ =
|
|
|
|
luadeps ++
|
|
|
|
(lib.concatMap (d : if d ? luadeps then d.luadeps else []) luadeps);
|
|
|
|
|
|
|
|
runtimeDeps_ =
|
|
|
|
runtimeDeps ++
|
|
|
|
(lib.concatMap (d : if d ? runtimeDeps then d.runtimeDeps else []) luadeps) ++
|
2016-03-21 09:51:20 +00:00
|
|
|
[ lua coreutils ];
|
2016-03-14 09:32:48 +00:00
|
|
|
|
|
|
|
mkcfg = ''
|
|
|
|
export LUAROCKS_CONFIG=config.lua
|
|
|
|
cat >config.lua <<EOF
|
|
|
|
rocks_trees = {
|
|
|
|
{ name = [[system]], root = [[${luarocks}]] }
|
|
|
|
${lib.concatImapStrings (i : dep : ", { name = [[dep${toString i}]], root = [[${dep}]] }") luadeps_}
|
|
|
|
};
|
|
|
|
|
|
|
|
variables = {
|
|
|
|
LUA_BINDIR = "$out/bin";
|
|
|
|
LUA_INCDIR = "$out/include";
|
2016-03-21 09:51:20 +00:00
|
|
|
LUA_LIBDIR = "$out/lib/lua/${lua.luaversion}";
|
2016-03-14 09:32:48 +00:00
|
|
|
};
|
|
|
|
EOF
|
|
|
|
'';
|
|
|
|
|
|
|
|
in
|
|
|
|
stdenv.mkDerivation (args // {
|
|
|
|
|
2018-05-24 05:37:33 +01:00
|
|
|
name = "${args.name}-${lua.luaversion}";
|
|
|
|
|
2016-03-14 09:32:48 +00:00
|
|
|
inherit preBuild postInstall;
|
|
|
|
|
|
|
|
inherit luadeps runtimeDeps;
|
|
|
|
|
|
|
|
phases = [ "unpackPhase" "patchPhase" "buildPhase"];
|
|
|
|
|
2016-03-21 09:51:20 +00:00
|
|
|
buildInputs = runtimeDeps ++ buildInputs ++ [ makeWrapper lua ];
|
2016-03-14 09:32:48 +00:00
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
eval "$preBuild"
|
|
|
|
${mkcfg}
|
|
|
|
eval "`${luarocks}/bin/luarocks --deps-mode=all --tree=$out path`"
|
|
|
|
${luarocks}/bin/luarocks make --deps-mode=all --tree=$out ${rockspec}
|
|
|
|
|
|
|
|
for p in $out/bin/*; do
|
|
|
|
wrapProgram $p \
|
2016-04-13 13:53:51 +01:00
|
|
|
--suffix LD_LIBRARY_PATH ';' "${lib.makeLibraryPath runtimeDeps_}" \
|
|
|
|
--suffix PATH ';' "${lib.makeBinPath runtimeDeps_}" \
|
2016-03-16 20:52:09 +00:00
|
|
|
--suffix LUA_PATH ';' "\"$LUA_PATH\"" \
|
2016-03-21 09:51:20 +00:00
|
|
|
--suffix LUA_PATH ';' "\"$out/share/lua/${lua.luaversion}/?.lua;$out/share/lua/${lua.luaversion}/?/init.lua\"" \
|
2016-03-16 20:52:09 +00:00
|
|
|
--suffix LUA_CPATH ';' "\"$LUA_CPATH\"" \
|
2016-03-21 09:51:20 +00:00
|
|
|
--suffix LUA_CPATH ';' "\"$out/lib/lua/${lua.luaversion}/?.so;$out/lib/lua/${lua.luaversion}/?/init.so\""
|
2016-03-14 09:32:48 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
eval "$postInstall"
|
|
|
|
'';
|
|
|
|
});
|
|
|
|
|
|
|
|
# FIXME: doesn't installs lua-files for some reason
|
|
|
|
# lua-cjson = buildLuaPackage {
|
|
|
|
# name = "lua-cjson";
|
|
|
|
# src = ./extra/lua-cjson;
|
|
|
|
# rockspec = "lua-cjson-2.1devel-1.rockspec";
|
|
|
|
# };
|
|
|
|
|
2019-08-13 22:52:01 +01:00
|
|
|
lua-cjson = stdenv.mkDerivation {
|
2016-03-14 09:32:48 +00:00
|
|
|
name = "lua-cjson";
|
|
|
|
src = "${distro_src}/extra/lua-cjson";
|
|
|
|
|
|
|
|
preConfigure = ''
|
|
|
|
makeFlags="PREFIX=$out LUA_LIBRARY=$out/lib/lua"
|
|
|
|
'';
|
|
|
|
|
2016-03-21 09:51:20 +00:00
|
|
|
buildInputs = [lua];
|
2016-03-14 09:32:48 +00:00
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
make install-extra $makeFlags
|
|
|
|
'';
|
2017-09-28 22:16:18 +01:00
|
|
|
meta.broken = true;
|
2016-03-14 09:32:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
luafilesystem = buildLuaRocks {
|
|
|
|
name = "filesystem";
|
|
|
|
src = "${distro_src}/extra/luafilesystem";
|
|
|
|
luadeps = [lua-cjson];
|
|
|
|
rockspec = "rockspecs/luafilesystem-1.6.3-1.rockspec";
|
|
|
|
};
|
|
|
|
|
|
|
|
penlight = buildLuaRocks {
|
|
|
|
name = "penlight";
|
|
|
|
src = "${distro_src}/extra/penlight";
|
|
|
|
luadeps = [luafilesystem];
|
|
|
|
};
|
|
|
|
|
|
|
|
luaffifb = buildLuaRocks {
|
|
|
|
name = "luaffifb";
|
|
|
|
src = "${distro_src}/extra/luaffifb";
|
2017-09-28 22:16:18 +01:00
|
|
|
meta.broken = true;
|
2016-03-14 09:32:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
sundown = buildLuaRocks rec {
|
|
|
|
name = "sundown";
|
|
|
|
src = "${distro_src}/pkg/sundown";
|
|
|
|
rockspec = "rocks/${name}-scm-1.rockspec";
|
2018-04-11 10:58:39 +01:00
|
|
|
meta.broken = true; # 2018-04-11
|
2016-03-14 09:32:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
cwrap = buildLuaRocks rec {
|
|
|
|
name = "cwrap";
|
|
|
|
src = "${distro_src}/pkg/cwrap";
|
|
|
|
rockspec = "rocks/${name}-scm-1.rockspec";
|
|
|
|
};
|
|
|
|
|
|
|
|
paths = buildLuaRocks rec {
|
|
|
|
name = "paths";
|
|
|
|
src = "${distro_src}/pkg/paths";
|
|
|
|
buildInputs = [cmake];
|
|
|
|
rockspec = "rocks/${name}-scm-1.rockspec";
|
|
|
|
};
|
|
|
|
|
|
|
|
torch = buildLuaRocks rec {
|
|
|
|
name = "torch";
|
|
|
|
src = "${distro_src}/pkg/torch";
|
|
|
|
luadeps = [ paths cwrap ];
|
|
|
|
buildInputs = [ cmake ];
|
|
|
|
rockspec = "rocks/torch-scm-1.rockspec";
|
|
|
|
preBuild = ''
|
|
|
|
substituteInPlace ${rockspec} \
|
|
|
|
--replace '"sys >= 1.0"' ' '
|
|
|
|
export LUA_PATH="$src/?.lua;$LUA_PATH"
|
|
|
|
'';
|
|
|
|
meta = common_meta // {
|
|
|
|
description = "Torch is a machine-learning library";
|
|
|
|
longDescription = ''
|
|
|
|
Torch is the main package in [Torch7](http://torch.ch) where data
|
|
|
|
structures for multi-dimensional tensors and mathematical operations
|
|
|
|
over these are defined. Additionally, it provides many utilities for
|
|
|
|
accessing files, serializing objects of arbitrary types and other
|
|
|
|
useful utilities.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
dok = buildLuaRocks rec {
|
|
|
|
name = "dok";
|
|
|
|
src = "${distro_src}/pkg/dok";
|
|
|
|
luadeps = [sundown];
|
|
|
|
rockspec = "rocks/${name}-scm-1.rockspec";
|
|
|
|
};
|
|
|
|
|
2019-08-13 22:52:01 +01:00
|
|
|
sys = buildLuaRocks {
|
2016-03-14 09:32:48 +00:00
|
|
|
name = "sys";
|
|
|
|
luadeps = [torch];
|
|
|
|
buildInputs = [readline cmake];
|
|
|
|
src = "${distro_src}/pkg/sys";
|
|
|
|
rockspec = "sys-1.1-0.rockspec";
|
|
|
|
preBuild = ''
|
|
|
|
export Torch_DIR=${torch}/share/cmake/torch
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2019-08-13 22:52:01 +01:00
|
|
|
xlua = buildLuaRocks {
|
2016-03-14 09:32:48 +00:00
|
|
|
name = "xlua";
|
|
|
|
luadeps = [torch sys];
|
|
|
|
src = "${distro_src}/pkg/xlua";
|
|
|
|
rockspec = "xlua-1.0-0.rockspec";
|
|
|
|
};
|
|
|
|
|
2019-08-13 22:52:01 +01:00
|
|
|
nn = buildLuaRocks {
|
2016-03-14 09:32:48 +00:00
|
|
|
name = "nn";
|
|
|
|
luadeps = [torch luaffifb];
|
|
|
|
buildInputs = [cmake];
|
|
|
|
src = "${distro_src}/extra/nn";
|
|
|
|
rockspec = "rocks/nn-scm-1.rockspec";
|
|
|
|
preBuild = ''
|
|
|
|
export Torch_DIR=${torch}/share/cmake/torch
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2019-08-13 22:52:01 +01:00
|
|
|
graph = buildLuaRocks {
|
2016-03-14 09:32:48 +00:00
|
|
|
name = "graph";
|
|
|
|
luadeps = [ torch ];
|
|
|
|
buildInputs = [cmake];
|
|
|
|
src = "${distro_src}/extra/graph";
|
|
|
|
rockspec = "rocks/graph-scm-1.rockspec";
|
|
|
|
preBuild = ''
|
|
|
|
export Torch_DIR=${torch}/share/cmake/torch
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2019-08-13 22:52:01 +01:00
|
|
|
nngraph = buildLuaRocks {
|
2016-03-14 09:32:48 +00:00
|
|
|
name = "nngraph";
|
|
|
|
luadeps = [ torch nn graph ];
|
|
|
|
buildInputs = [cmake];
|
|
|
|
src = "${distro_src}/extra/nngraph";
|
|
|
|
preBuild = ''
|
|
|
|
export Torch_DIR=${torch}/share/cmake/torch
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2019-08-13 22:52:01 +01:00
|
|
|
image = buildLuaRocks {
|
2016-03-14 09:32:48 +00:00
|
|
|
name = "image";
|
|
|
|
luadeps = [ torch dok sys xlua ];
|
2016-03-21 21:37:56 +00:00
|
|
|
buildInputs = [cmake libjpeg libpng];
|
2016-03-14 09:32:48 +00:00
|
|
|
src = "${distro_src}/pkg/image";
|
|
|
|
rockspec = "image-1.1.alpha-0.rockspec";
|
|
|
|
preBuild = ''
|
|
|
|
export Torch_DIR=${torch}/share/cmake/torch
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2019-08-13 22:52:01 +01:00
|
|
|
optim = buildLuaRocks {
|
2016-03-14 09:32:48 +00:00
|
|
|
name = "optim";
|
|
|
|
luadeps = [ torch ];
|
|
|
|
buildInputs = [cmake];
|
|
|
|
src = "${distro_src}/pkg/optim";
|
|
|
|
rockspec = "optim-1.0.5-0.rockspec";
|
|
|
|
preBuild = ''
|
|
|
|
export Torch_DIR=${torch}/share/cmake/torch
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2019-08-13 22:52:01 +01:00
|
|
|
gnuplot = buildLuaRocks {
|
2016-03-14 09:32:48 +00:00
|
|
|
name = "gnuplot";
|
|
|
|
luadeps = [ torch paths ];
|
|
|
|
runtimeDeps = [ pkgs_gnuplot less ];
|
|
|
|
src = "${distro_src}/pkg/gnuplot";
|
|
|
|
rockspec = "rocks/gnuplot-scm-1.rockspec";
|
|
|
|
};
|
|
|
|
|
2019-08-13 22:52:01 +01:00
|
|
|
unsup = buildLuaRocks {
|
2016-03-22 16:42:32 +00:00
|
|
|
name = "unsup";
|
|
|
|
luadeps = [ torch xlua optim ];
|
|
|
|
buildInputs = [ cmake ];
|
|
|
|
src = fetchgit {
|
|
|
|
url = "https://github.com/koraykv/unsup";
|
|
|
|
rev = "1d4632e716dc3c82feecc7dd4b22549df442859f";
|
|
|
|
sha256 = "0npjq3y1cfmk026sdijcw3f766innrmb3qggnxsz62grczhfvgls";
|
|
|
|
};
|
|
|
|
rockspec = "unsup-0.1-0.rockspec";
|
|
|
|
preBuild = ''
|
|
|
|
export Torch_DIR=${torch}/share/cmake/torch
|
|
|
|
'';
|
2017-09-28 22:16:18 +01:00
|
|
|
meta.broken = true;
|
2016-03-22 16:42:32 +00:00
|
|
|
};
|
|
|
|
|
2019-08-13 22:52:01 +01:00
|
|
|
trepl = buildLuaRocks {
|
2016-03-14 09:32:48 +00:00
|
|
|
name = "trepl";
|
2016-03-22 16:42:32 +00:00
|
|
|
luadeps = [torch gnuplot paths penlight graph nn nngraph image gnuplot optim sys dok unsup];
|
2016-03-14 09:32:48 +00:00
|
|
|
runtimeDeps = [ ncurses readline ];
|
|
|
|
src = "${distro_src}/exe/trepl";
|
|
|
|
meta = common_meta // {
|
2016-03-21 09:51:20 +00:00
|
|
|
description = "A pure Lua REPL for Lua(JIT), with heavy support for Torch types.";
|
2016-03-14 09:32:48 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2019-08-13 22:52:01 +01:00
|
|
|
lbase64 = buildLuaRocks {
|
2016-03-14 09:32:48 +00:00
|
|
|
name = "lbase64";
|
|
|
|
src = fetchgit {
|
|
|
|
url = "https://github.com/LuaDist2/lbase64";
|
|
|
|
rev = "1e9e4f1e0bf589a0ed39f58acc185ec5e213d207";
|
|
|
|
sha256 = "1i1fpy9v6r4w3lrmz7bmf5ppq65925rv90gx39b3pykfmn0hcb9c";
|
|
|
|
};
|
2018-04-11 10:58:39 +01:00
|
|
|
meta.broken = true; # 2018-04-11
|
2016-03-14 09:32:48 +00:00
|
|
|
};
|
|
|
|
|
2019-08-13 22:52:01 +01:00
|
|
|
luuid = stdenv.mkDerivation {
|
2016-03-14 09:32:48 +00:00
|
|
|
name = "luuid";
|
|
|
|
src = fetchgit {
|
|
|
|
url = "https://github.com/LuaDist/luuid";
|
|
|
|
sha256 = "062gdf1rild11jg46vry93hcbb36b4527pf1dy7q9fv89f7m2nav";
|
|
|
|
};
|
|
|
|
|
|
|
|
preConfigure = ''
|
2016-03-21 09:51:20 +00:00
|
|
|
cmakeFlags="-DLUA_LIBRARY=${lua}/lib/lua/${lua.luaversion} -DINSTALL_CMOD=$out/lib/lua/${lua.luaversion} -DINSTALL_MOD=$out/lib/lua/${lua.luaversion}"
|
2016-03-14 09:32:48 +00:00
|
|
|
'';
|
|
|
|
|
2016-03-21 09:51:20 +00:00
|
|
|
buildInputs = [cmake libuuid lua];
|
2016-03-14 09:32:48 +00:00
|
|
|
meta = {
|
|
|
|
# FIXME: set the exact revision for src
|
|
|
|
broken = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
# Doesn't work due to missing deps (according to luarocs).
|
2019-08-13 22:52:01 +01:00
|
|
|
itorch = buildLuaRocks {
|
2016-03-14 09:32:48 +00:00
|
|
|
name = "itorch";
|
|
|
|
luadeps = [torch gnuplot paths penlight graph nn nngraph image gnuplot
|
|
|
|
optim sys dok lbase64 lua-cjson luuid];
|
|
|
|
buildInputs = [czmq openssl];
|
|
|
|
src = "${distro_src}/extra/iTorch";
|
|
|
|
meta = {
|
|
|
|
# FIXME: figure out whats wrong with deps
|
|
|
|
broken = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
luapkgs
|
|
|
|
|
|
|
|
|