cleverca22
10/23/2015 - 9:55 AM

cwrap.nix

with import <nixpkgs> {};

let
  cwrap = pkgs.callPackage ./cwrap.nix {};
in
stdenv.mkDerivation rec {
  name = "torch-7";

  src = fetchFromGitHub {
    owner = "torch";
    repo = "torch7";
    rev = "adfee5da9740aab2ebf647ecffe1102e8e3ccef5";
    sha256 = "0bl2ygfyapvfb2z5w2wk6v0ayg82a5xxh1449shvn7wv1815qs9g";
  };

  cmakeFlags = [ "-DLUA=${pkgs.lua}/bin/lua" ];

  buildInputs = [ cwrap cmake readline qt4 libjpeg libpng ncurses imagemagick gfortran gnuplot lua ];
}
{ stdenv, lua, fetchFromGitHub }:

stdenv.mkDerivation rec {
  name = "cwrap-7";

  src = fetchFromGitHub {
    owner = "torch";
    repo = "cwrap";
    rev = "6e7d52f0a359dee47127386adb03c0dc4ddd4766";
    sha256 = "01yh9z0axz0b4f87mbhkzh64dyv6c4jdkazcpmy1bl1am8apbd8w";
  };

  installPhase = ''
    mkdir -p $out/share/lua/5.2/cwrap/ $out/nix-support
    cp -v init.lua types.lua cinterface.lua $out/share/lua/5.2/cwrap/
    cat <<EOF > $out/nix-support/setup-hook
    # FIXME, overrides all other lua packages, doesnt persist past compile
    export LUA_PATH=$out/share/lua/5.2/?/init.lua\;$out/share/lua/5.2/?.lua\;?.lua
    EOF
  '';

  buildInputs = [ lua ];
}