diff options
author | Matthieu Coudron <coudron@iij.ad.jp> | 2019-01-30 23:13:15 +0900 |
---|---|---|
committer | Michael Raskin <7c6f434c@mail.ru> | 2019-01-30 14:13:15 +0000 |
commit | c4519cf8a6bfdb21ced8b053953d2a8fa68c615c (patch) | |
tree | 3ea0dac7056b81a28f024d1db2df0ce97354a240 /pkgs/development/interpreters/luajit/default.nix | |
parent | 16ab34c37b7ead2266ae24ebcf5d6e9f5cd5ab59 (diff) |
lua: add withPackages function (#54460)
* lua: add withPackages function First step towards more automation similar to the haskell backend. Follow up of https://github.com/NixOS/nixpkgs/pull/33903
Diffstat (limited to 'pkgs/development/interpreters/luajit/default.nix')
-rw-r--r-- | pkgs/development/interpreters/luajit/default.nix | 121 |
1 files changed, 62 insertions, 59 deletions
diff --git a/pkgs/development/interpreters/luajit/default.nix b/pkgs/development/interpreters/luajit/default.nix index 9ee628f498ee6..c95b9e8b8e37e 100644 --- a/pkgs/development/interpreters/luajit/default.nix +++ b/pkgs/development/interpreters/luajit/default.nix @@ -1,71 +1,74 @@ -{ stdenv, lib, fetchurl }: -rec { +{ stdenv, lib, fetchurl +, name ? "luajit-${version}" +, isStable +, sha256 +, version +, extraMeta ? {} +, callPackage +, self +, packageOverrides ? (self: super: {}) +}: +let + luaPackages = callPackage ../../lua-modules {lua=self; overrides=packageOverrides;}; +in +stdenv.mkDerivation rec { + inherit name version; + src = fetchurl { + url = "http://luajit.org/download/LuaJIT-${version}.tar.gz"; + inherit sha256; + }; - luajit = luajit_2_1; + luaversion = "5.1"; - luajit_2_0 = generic { - version = "2.0.5"; - isStable = true; - sha256 = "0yg9q4q6v028bgh85317ykc9whgxgysp76qzaqgq55y6jy11yjw7"; - meta = genericMeta // { - platforms = lib.filter (p: p != "aarch64-linux") genericMeta.platforms; - }; - }; + patchPhase = '' + substituteInPlace Makefile \ + --replace /usr/local "$out" + + substituteInPlace src/Makefile --replace gcc cc + '' + stdenv.lib.optionalString (stdenv.cc.libc != null) + '' + substituteInPlace Makefile \ + --replace ldconfig ${stdenv.cc.libc.bin or stdenv.cc.libc}/bin/ldconfig + ''; + + configurePhase = false; - luajit_2_1 = generic { - version = "2.1.0-beta3"; - isStable = false; - sha256 = "1hyrhpkwjqsv54hnnx4cl8vk44h9d6c9w0fz1jfjz00w255y7lhs"; + buildFlags = [ "amalg" ]; # Build highly optimized version + enableParallelBuilding = true; + + installPhase = '' + make install PREFIX="$out" + ( cd "$out/include"; ln -s luajit-*/* . ) + ln -s "$out"/bin/luajit-* "$out"/bin/lua + '' + + stdenv.lib.optionalString (!isStable) '' + ln -s "$out"/bin/luajit-* "$out"/bin/luajit + ''; + + LuaPathSearchPaths = [ + "lib/lua/${luaversion}/?.lua" "share/lua/${luaversion}/?.lua" + "share/lua/${luaversion}/?/init.lua" "lib/lua/${luaversion}/?/init.lua" + "share/${name}/?.lua" + ]; + LuaCPathSearchPaths = [ "lib/lua/${luaversion}/?.so" "share/lua/${luaversion}/?.so" ]; + setupHook = luaPackages.lua-setup-hook LuaPathSearchPaths LuaCPathSearchPaths; + + passthru = rec { + buildEnv = callPackage ../lua-5/wrapper.nix { + lua = self; + inherit (luaPackages) requiredLuaModules; + }; + withPackages = import ../lua-5/with-packages.nix { inherit buildEnv luaPackages;}; + pkgs = luaPackages; + interpreter = "${self}/bin/lua"; }; - genericMeta = with stdenv.lib; { + meta = with stdenv.lib; extraMeta // { description = "High-performance JIT compiler for Lua 5.1"; homepage = http://luajit.org; license = licenses.mit; platforms = platforms.linux ++ platforms.darwin; maintainers = with maintainers; [ thoughtpolice smironov vcunat andir ]; }; - - generic = - { version, sha256 ? null, isStable - , name ? "luajit-${version}" - , src ? - (fetchurl { - url = "http://luajit.org/download/LuaJIT-${version}.tar.gz"; - inherit sha256; - }) - , meta ? genericMeta - }: - - stdenv.mkDerivation rec { - inherit name version src meta; - - luaversion = "5.1"; - - patchPhase = '' - substituteInPlace Makefile \ - --replace /usr/local "$out" - - substituteInPlace src/Makefile --replace gcc cc - '' + stdenv.lib.optionalString (stdenv.cc.libc != null) - '' - substituteInPlace Makefile \ - --replace ldconfig ${stdenv.cc.libc.bin or stdenv.cc.libc}/bin/ldconfig - ''; - - configurePhase = false; - - buildFlags = [ "amalg" ]; # Build highly optimized version - enableParallelBuilding = true; - - installPhase = '' - make install PREFIX="$out" - ( cd "$out/include"; ln -s luajit-*/* . ) - ln -s "$out"/bin/luajit-* "$out"/bin/lua - '' - + stdenv.lib.optionalString (!isStable) - '' - ln -s "$out"/bin/luajit-* "$out"/bin/luajit - ''; - }; } + |