diff options
Diffstat (limited to 'nixpkgs/pkgs/development/tools/misc/luarocks')
5 files changed, 128 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/tools/misc/luarocks/darwin.patch b/nixpkgs/pkgs/development/tools/misc/luarocks/darwin.patch new file mode 100644 index 000000000000..ec7f924987a2 --- /dev/null +++ b/nixpkgs/pkgs/development/tools/misc/luarocks/darwin.patch @@ -0,0 +1,27 @@ +diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua +index 55cd4c9..060a6f1 100644 +--- a/src/luarocks/cfg.lua ++++ b/src/luarocks/cfg.lua +@@ -587,9 +587,9 @@ if cfg.platforms.macosx then + defaults.external_lib_extension = "dylib" + defaults.arch = "macosx-"..cfg.target_cpu + defaults.variables.LIBFLAG = "-bundle -undefined dynamic_lookup -all_load" +- defaults.variables.STAT = "/usr/bin/stat" ++ defaults.variables.STAT = "stat" + defaults.variables.STATFLAG = "-f '%A'" +- local version = io.popen("sw_vers -productVersion"):read("*l") ++ local version = "10.10" + version = tonumber(version and version:match("^[^.]+%.([^.]+)")) or 3 + if version >= 10 then + version = 8 +@@ -598,8 +598,8 @@ if cfg.platforms.macosx then + else + defaults.gcc_rpath = false + end +- defaults.variables.CC = "env MACOSX_DEPLOYMENT_TARGET=10."..version.." gcc" +- defaults.variables.LD = "env MACOSX_DEPLOYMENT_TARGET=10."..version.." gcc" ++ defaults.variables.CC = "env MACOSX_DEPLOYMENT_TARGET=10."..version.." clang" ++ defaults.variables.LD = "env MACOSX_DEPLOYMENT_TARGET=10."..version.." clang" + defaults.web_browser = "open" + end + diff --git a/nixpkgs/pkgs/development/tools/misc/luarocks/default.nix b/nixpkgs/pkgs/development/tools/misc/luarocks/default.nix new file mode 100644 index 000000000000..5e418fcfdcfd --- /dev/null +++ b/nixpkgs/pkgs/development/tools/misc/luarocks/default.nix @@ -0,0 +1,75 @@ +{stdenv, fetchurl +, curl, makeWrapper, which, unzip +, lua +# for 'luarocks pack' +, zip +# some packages need to be compiled with cmake +, cmake +}: + +let +in + +stdenv.mkDerivation rec { + pname="luarocks"; + version="2.4.4"; + + src = fetchurl { + url="http://luarocks.org/releases/luarocks-${version}.tar.gz"; + sha256="0d7rl60dwh52qh5pfsphgx5ypp7k190h9ri6qpr2yx9kvqrxyf1r"; + }; + + patches = [ ./darwin.patch ]; + preConfigure = '' + lua -e "" || { + luajit -e "" && { + export LUA_SUFFIX=jit + configureFlags="$configureFlags --lua-suffix=$LUA_SUFFIX" + } + } + lua_inc="$(echo "${lua}/include"/*/)" + if test -n "$lua_inc"; then + configureFlags="$configureFlags --with-lua-include=$lua_inc" + fi + ''; + + buildInputs = [ + lua curl makeWrapper which + ]; + + postInstall = '' + sed -e "1s@.*@#! ${lua}/bin/lua$LUA_SUFFIX@" -i "$out"/bin/* + for i in "$out"/bin/*; do + test -L "$i" || { + wrapProgram "$i" \ + --suffix LUA_PATH ";" "$(echo "$out"/share/lua/*/)?.lua" \ + --suffix LUA_PATH ";" "$(echo "$out"/share/lua/*/)?/init.lua" \ + --suffix LUA_CPATH ";" "$(echo "$out"/lib/lua/*/)?.so" \ + --suffix LUA_CPATH ";" "$(echo "$out"/share/lua/*/)?/init.lua" + } + done + ''; + + propagatedBuildInputs = [ zip unzip cmake ]; + + # unpack hook for src.rock and rockspec files + setupHook = ./setup-hook.sh; + + # cmake is just to compile packages with "cmake" buildType, not luarocks itself + dontUseCmakeConfigure = true; + + shellHook = '' + export PATH="src/bin:''${PATH:-}" + export LUA_PATH="src/?.lua;''${LUA_PATH:-}" + ''; + + meta = with stdenv.lib; { + inherit version; + description = ''A package manager for Lua''; + license = licenses.mit ; + maintainers = with maintainers; [raskin teto]; + platforms = platforms.linux ++ platforms.darwin; + downloadPage = "http://luarocks.org/releases/"; + updateWalker = true; + }; +} diff --git a/nixpkgs/pkgs/development/tools/misc/luarocks/default.upstream b/nixpkgs/pkgs/development/tools/misc/luarocks/default.upstream new file mode 100644 index 000000000000..e69de1fe8895 --- /dev/null +++ b/nixpkgs/pkgs/development/tools/misc/luarocks/default.upstream @@ -0,0 +1 @@ +url http://luarocks.org/releases/ diff --git a/nixpkgs/pkgs/development/tools/misc/luarocks/luarocks-nix.nix b/nixpkgs/pkgs/development/tools/misc/luarocks/luarocks-nix.nix new file mode 100644 index 000000000000..a918cb0c6475 --- /dev/null +++ b/nixpkgs/pkgs/development/tools/misc/luarocks/luarocks-nix.nix @@ -0,0 +1,9 @@ +{ luarocks, fetchFromGitHub }: +luarocks.overrideAttrs(old: { + src = fetchFromGitHub { + owner = "teto"; + repo = "luarocks"; + rev = "f9dc7892214bff6bce822d94aca3331048e61df0"; + sha256 = "117qqbiv87p2qw0zwapl7b0p4wgnn9f8k0qpppkj3653a1bwli05"; + }; +}) diff --git a/nixpkgs/pkgs/development/tools/misc/luarocks/setup-hook.sh b/nixpkgs/pkgs/development/tools/misc/luarocks/setup-hook.sh new file mode 100644 index 000000000000..587d5413c3ed --- /dev/null +++ b/nixpkgs/pkgs/development/tools/misc/luarocks/setup-hook.sh @@ -0,0 +1,16 @@ +unpackCmdHooks+=(_trySourceRock) +unpackCmdHooks+=(_tryRockSpec) + +_tryRockSpec() { + if ! [[ "$curSrc" =~ \.rockspec$ ]]; then return 1; fi +} + +_trySourceRock() { + if ! [[ "$curSrc" =~ \.src.rock$ ]]; then return 1; fi + + # luarocks expects a clean <name>.rock.spec name to be the package name + # so we have to strip the hash + renamed="$(stripHash $curSrc)" + cp "$curSrc" "$renamed" + luarocks unpack --force "$renamed" +} |