uboot: (firmwareOdroidC2/C4) don't invoke patch tool, use patches = [] instead
https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/setup.sh#L948 this can do it nicely. Signed-off-by: Anton Arapov <anton@deadbeef.mx>
This commit is contained in:
commit
56de2bcd43
30691 changed files with 3076956 additions and 0 deletions
52
pkgs/development/interpreters/lua-5/5.1.darwin.patch
Normal file
52
pkgs/development/interpreters/lua-5/5.1.darwin.patch
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
diff --git a/Makefile b/Makefile
|
||||
index 209a132..9387b09 100644
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -43,7 +43,7 @@ PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris
|
||||
# What to install.
|
||||
TO_BIN= lua luac
|
||||
TO_INC= lua.h luaconf.h lualib.h lauxlib.h ../etc/lua.hpp
|
||||
-TO_LIB= liblua.a
|
||||
+TO_LIB= liblua.5.1.5.dylib
|
||||
TO_MAN= lua.1 luac.1
|
||||
|
||||
# Lua version and release.
|
||||
@@ -64,6 +64,8 @@ install: dummy
|
||||
cd src && $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC)
|
||||
cd src && $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB)
|
||||
cd doc && $(INSTALL_DATA) $(TO_MAN) $(INSTALL_MAN)
|
||||
+ ln -s -f liblua.5.1.5.dylib $(INSTALL_LIB)/liblua.5.1.dylib
|
||||
+ ln -s -f liblua.5.1.dylib $(INSTALL_LIB)/liblua.dylib
|
||||
|
||||
ranlib:
|
||||
cd src && cd $(INSTALL_LIB) && $(RANLIB) $(TO_LIB)
|
||||
diff --git a/src/Makefile b/src/Makefile
|
||||
index e0d4c9f..4477d7b 100644
|
||||
--- a/src/Makefile
|
||||
+++ b/src/Makefile
|
||||
@@ -22,7 +22,7 @@ MYLIBS=
|
||||
|
||||
PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris
|
||||
|
||||
-LUA_A= liblua.a
|
||||
+LUA_A= liblua.5.1.5.dylib
|
||||
CORE_O= lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \
|
||||
lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o \
|
||||
lundump.o lvm.o lzio.o
|
||||
@@ -48,11 +48,13 @@ o: $(ALL_O)
|
||||
a: $(ALL_A)
|
||||
|
||||
$(LUA_A): $(CORE_O) $(LIB_O)
|
||||
- $(AR) $@ $(CORE_O) $(LIB_O) # DLL needs all object files
|
||||
- $(RANLIB) $@
|
||||
+ $(CC) -dynamiclib -install_name $(out)/lib/liblua.5.1.dylib \
|
||||
+ -compatibility_version 5.1 -current_version 5.1.5 \
|
||||
+ -o liblua.5.1.5.dylib $^
|
||||
|
||||
$(LUA_T): $(LUA_O) $(LUA_A)
|
||||
- $(CC) -o $@ $(MYLDFLAGS) $(LUA_O) $(LUA_A) $(LIBS)
|
||||
+ $(CC) -fno-common $(MYLDFLAGS) \
|
||||
+ -o $@ $(LUA_O) $(LUA_A) -L. -llua.5.1.5 $(LIBS)
|
||||
|
||||
$(LUAC_T): $(LUAC_O) $(LUA_A)
|
||||
$(CC) -o $@ $(MYLDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS)
|
||||
52
pkgs/development/interpreters/lua-5/5.2.darwin.patch
Normal file
52
pkgs/development/interpreters/lua-5/5.2.darwin.patch
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
diff --git a/Makefile b/Makefile
|
||||
index d2c7db4..dc107b3 100644
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -41,7 +41,7 @@ PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris
|
||||
# What to install.
|
||||
TO_BIN= lua luac
|
||||
TO_INC= lua.h luaconf.h lualib.h lauxlib.h lua.hpp
|
||||
-TO_LIB= liblua.a
|
||||
+TO_LIB= liblua.${version}.dylib
|
||||
TO_MAN= lua.1 luac.1
|
||||
|
||||
# Lua version and release.
|
||||
@@ -63,6 +63,8 @@ install: dummy
|
||||
cd src && $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC)
|
||||
cd src && $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB)
|
||||
cd doc && $(INSTALL_DATA) $(TO_MAN) $(INSTALL_MAN)
|
||||
+ ln -s -f liblua.${version}.dylib $(INSTALL_LIB)/liblua.${luaversion}.dylib
|
||||
+ ln -s -f liblua.${luaversion}.dylib $(INSTALL_LIB)/liblua.dylib
|
||||
|
||||
uninstall:
|
||||
cd src && cd $(INSTALL_BIN) && $(RM) $(TO_BIN)
|
||||
diff --git a/src/Makefile b/src/Makefile
|
||||
index 7b4b2b7..25001e5 100644
|
||||
--- a/src/Makefile
|
||||
+++ b/src/Makefile
|
||||
@@ -28,7 +28,7 @@ MYOBJS=
|
||||
|
||||
PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris
|
||||
|
||||
-LUA_A= liblua.a
|
||||
+LUA_A= liblua.${version}.dylib
|
||||
CORE_O= lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o \
|
||||
lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o \
|
||||
ltm.o lundump.o lvm.o lzio.o
|
||||
@@ -56,11 +56,13 @@ o: $(ALL_O)
|
||||
a: $(ALL_A)
|
||||
|
||||
$(LUA_A): $(BASE_O)
|
||||
- $(AR) $@ $(BASE_O)
|
||||
- $(RANLIB) $@
|
||||
+ $(CC) -dynamiclib -install_name $(out)/lib/liblua.${version}.dylib \
|
||||
+ -compatibility_version ${version} -current_version ${version} \
|
||||
+ -o liblua.${version}.dylib $^
|
||||
|
||||
$(LUA_T): $(LUA_O) $(LUA_A)
|
||||
- $(CC) -o $@ $(LDFLAGS) $(LUA_O) $(LUA_A) $(LIBS)
|
||||
+ $(CC) -fno-common $(MYLDFLAGS) \
|
||||
+ -o $@ $(LUA_O) $(LUA_A) -L. -llua.${version} $(LIBS)
|
||||
|
||||
$(LUAC_T): $(LUAC_O) $(LUA_A)
|
||||
$(CC) -o $@ $(LDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS)
|
||||
48
pkgs/development/interpreters/lua-5/5.4.darwin.patch
Normal file
48
pkgs/development/interpreters/lua-5/5.4.darwin.patch
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
--- a/Makefile 2021-05-14 22:39:14.407200562 +0300
|
||||
+++ b/Makefile 2021-05-14 22:36:23.828513407 +0300
|
||||
@@ -41,7 +41,7 @@
|
||||
# What to install.
|
||||
TO_BIN= lua luac
|
||||
TO_INC= lua.h luaconf.h lualib.h lauxlib.h lua.hpp
|
||||
-TO_LIB= liblua.a
|
||||
+TO_LIB= liblua.${version}.dylib
|
||||
TO_MAN= lua.1 luac.1
|
||||
|
||||
# Lua version and release.
|
||||
@@ -60,6 +60,8 @@
|
||||
cd src && $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC)
|
||||
cd src && $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB)
|
||||
cd doc && $(INSTALL_DATA) $(TO_MAN) $(INSTALL_MAN)
|
||||
+ ln -s -f liblua.${version}.dylib $(INSTALL_LIB)/liblua.${luaversion}.dylib
|
||||
+ ln -s -f liblua.${luaversion}.dylib $(INSTALL_LIB)/liblua.dylib
|
||||
|
||||
uninstall:
|
||||
cd src && cd $(INSTALL_BIN) && $(RM) $(TO_BIN)
|
||||
--- a/src/Makefile 2021-05-14 22:35:38.575051882 +0300
|
||||
+++ b/src/Makefile 2021-05-14 22:35:33.584631206 +0300
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
PLATS= guess aix bsd c89 freebsd generic linux linux-readline macosx mingw posix solaris
|
||||
|
||||
-LUA_A= liblua.a
|
||||
+LUA_A= liblua.${version}.dylib
|
||||
CORE_O= lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o lundump.o lvm.o lzio.o
|
||||
LIB_O= lauxlib.o lbaselib.o lcorolib.o ldblib.o liolib.o lmathlib.o loadlib.o loslib.o lstrlib.o ltablib.o lutf8lib.o linit.o
|
||||
BASE_O= $(CORE_O) $(LIB_O) $(MYOBJS)
|
||||
@@ -57,11 +57,13 @@
|
||||
a: $(ALL_A)
|
||||
|
||||
$(LUA_A): $(BASE_O)
|
||||
- $(AR) $@ $(BASE_O)
|
||||
- $(RANLIB) $@
|
||||
+ $(CC) -dynamiclib -install_name $(out)/lib/liblua.${version}.dylib \
|
||||
+ -compatibility_version ${version} -current_version ${version} \
|
||||
+ -o liblua.${version}.dylib $^
|
||||
|
||||
$(LUA_T): $(LUA_O) $(LUA_A)
|
||||
- $(CC) -o $@ $(LDFLAGS) $(LUA_O) $(LUA_A) $(LIBS)
|
||||
+ $(CC) -fno-common $(MYLDFLAGS) \
|
||||
+ -o $@ $(LUA_O) $(LUA_A) -L. -llua.${version} $(LIBS)
|
||||
|
||||
$(LUAC_T): $(LUAC_O) $(LUA_A)
|
||||
$(CC) -o $@ $(LDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS)
|
||||
21
pkgs/development/interpreters/lua-5/CVE-2014-5461.patch
Normal file
21
pkgs/development/interpreters/lua-5/CVE-2014-5461.patch
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
From: Enrico Tassi <gareuselesinge@debian.org>
|
||||
Date: Tue, 26 Aug 2014 16:20:55 +0200
|
||||
Subject: Fix stack overflow in vararg functions
|
||||
|
||||
---
|
||||
src/ldo.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/ldo.c b/src/ldo.c
|
||||
index d1bf786..30333bf 100644
|
||||
--- a/src/ldo.c
|
||||
+++ b/src/ldo.c
|
||||
@@ -274,7 +274,7 @@ int luaD_precall (lua_State *L, StkId func, int nresults) {
|
||||
CallInfo *ci;
|
||||
StkId st, base;
|
||||
Proto *p = cl->p;
|
||||
- luaD_checkstack(L, p->maxstacksize);
|
||||
+ luaD_checkstack(L, p->maxstacksize + p->numparams);
|
||||
func = restorestack(L, funcr);
|
||||
if (!p->is_vararg) { /* no varargs? */
|
||||
base = func + 1;
|
||||
207
pkgs/development/interpreters/lua-5/build-lua-package.nix
Normal file
207
pkgs/development/interpreters/lua-5/build-lua-package.nix
Normal file
|
|
@ -0,0 +1,207 @@
|
|||
# Generic builder for lua packages
|
||||
{ lib
|
||||
, lua
|
||||
, wrapLua
|
||||
# Whether the derivation provides a lua module or not.
|
||||
, toLuaModule
|
||||
}:
|
||||
|
||||
{
|
||||
pname
|
||||
, version
|
||||
|
||||
# by default prefix `name` e.g. "lua5.2-${name}"
|
||||
, namePrefix ? if lua.pkgs.isLuaJIT
|
||||
then lua.name + "-"
|
||||
else "lua" + lua.luaversion + "-"
|
||||
|
||||
# Dependencies for building the package
|
||||
, buildInputs ? []
|
||||
|
||||
# Dependencies needed for running the checkPhase.
|
||||
# These are added to buildInputs when doCheck = true.
|
||||
, checkInputs ? []
|
||||
|
||||
# propagate build dependencies so in case we have A -> B -> C,
|
||||
# C can import package A propagated by B
|
||||
, propagatedBuildInputs ? []
|
||||
|
||||
# used to disable derivation, useful for specific lua versions
|
||||
# TODO move from this setting meta.broken to a 'disabled' attribute on the
|
||||
# package, then use that to skip/include in each lua${ver}Packages set?
|
||||
, disabled ? false
|
||||
|
||||
# Additional arguments to pass to the makeWrapper function, which wraps
|
||||
# generated binaries.
|
||||
, makeWrapperArgs ? []
|
||||
|
||||
# Skip wrapping of lua programs altogether
|
||||
, dontWrapLuaPrograms ? false
|
||||
|
||||
, meta ? {}
|
||||
|
||||
, passthru ? {}
|
||||
, doCheck ? false
|
||||
|
||||
# Non-Lua / system (e.g. C library) dependencies. Is a list of deps, where
|
||||
# each dep is either a derivation, or an attribute set like
|
||||
# { name = "rockspec external_dependencies key"; dep = derivation; }
|
||||
# The latter is used to work-around luarocks having a problem with
|
||||
# multiple-output derivations as external deps:
|
||||
# https://github.com/luarocks/luarocks/issues/766<Paste>
|
||||
, externalDeps ? []
|
||||
|
||||
# Appended to the generated luarocks config
|
||||
, extraConfig ? ""
|
||||
# Inserted into the generated luarocks config in the "variables" table
|
||||
, extraVariables ? {}
|
||||
# The two above arguments have access to builder variables -- e.g. to $out
|
||||
|
||||
# relative to srcRoot, path to the rockspec to use when using rocks
|
||||
, rockspecFilename ? null
|
||||
# relative to srcRoot, path to folder that contains the expected rockspec
|
||||
, rockspecDir ? "."
|
||||
|
||||
# must be set for packages that don't have a rock
|
||||
, knownRockspec ? null
|
||||
|
||||
, ... } @ attrs:
|
||||
|
||||
|
||||
# Keep extra attributes from `attrs`, e.g., `patchPhase', etc.
|
||||
|
||||
let
|
||||
generatedRockspecFilename = "${rockspecDir}/${pname}-${version}.rockspec";
|
||||
|
||||
# TODO fix warnings "Couldn't load rockspec for ..." during manifest
|
||||
# construction -- from initial investigation, appears it will require
|
||||
# upstream luarocks changes to fix cleanly (during manifest construction,
|
||||
# luarocks only looks for rockspecs in the default/system tree instead of all
|
||||
# configured trees)
|
||||
luarocks_config = "luarocks-config.lua";
|
||||
luarocks_content = let
|
||||
generatedConfig = lua.pkgs.lib.generateLuarocksConfig {
|
||||
externalDeps = externalDeps ++ externalDepsGenerated;
|
||||
inherit extraVariables;
|
||||
inherit rocksSubdir;
|
||||
inherit requiredLuaRocks;
|
||||
};
|
||||
in
|
||||
''
|
||||
${generatedConfig}
|
||||
${extraConfig}
|
||||
'';
|
||||
|
||||
rocksSubdir = "${attrs.pname}-${version}-rocks";
|
||||
|
||||
# Filter out the lua derivation itself from the Lua module dependency
|
||||
# closure, as it doesn't have a rock tree :)
|
||||
requiredLuaRocks = lib.filter (d: d ? luaModule)
|
||||
(lua.pkgs.requiredLuaModules luarocksDrv.propagatedBuildInputs);
|
||||
|
||||
# example externalDeps': [ { name = "CRYPTO"; dep = pkgs.openssl; } ]
|
||||
externalDepsGenerated = lib.unique (lib.filter (drv: !drv ? luaModule) (luarocksDrv.propagatedBuildInputs ++ luarocksDrv.buildInputs));
|
||||
externalDeps' = lib.filter (dep: !lib.isDerivation dep) externalDeps;
|
||||
|
||||
luarocksDrv = toLuaModule ( lua.stdenv.mkDerivation (
|
||||
builtins.removeAttrs attrs ["disabled" "checkInputs" "externalDeps" "extraVariables"] // {
|
||||
|
||||
name = namePrefix + pname + "-" + version;
|
||||
|
||||
buildInputs = [ wrapLua lua.pkgs.luarocks ]
|
||||
++ buildInputs
|
||||
++ lib.optionals doCheck checkInputs
|
||||
++ (map (d: d.dep) externalDeps')
|
||||
;
|
||||
|
||||
# propagate lua to active setup-hook in nix-shell
|
||||
propagatedBuildInputs = propagatedBuildInputs ++ [ lua ];
|
||||
inherit doCheck;
|
||||
|
||||
# @-patterns do not capture formal argument default values, so we need to
|
||||
# explicitly inherit this for it to be available as a shell variable in the
|
||||
# builder
|
||||
inherit rocksSubdir;
|
||||
|
||||
configurePhase = ''
|
||||
runHook preConfigure
|
||||
|
||||
cat > ${luarocks_config} <<EOF
|
||||
${luarocks_content}
|
||||
EOF
|
||||
export LUAROCKS_CONFIG="$PWD/${luarocks_config}";
|
||||
''
|
||||
+ lib.optionalString (rockspecFilename == null) ''
|
||||
rockspecFilename="${generatedRockspecFilename}"
|
||||
''
|
||||
+ lib.optionalString (knownRockspec != null) ''
|
||||
|
||||
# prevents the following type of error:
|
||||
# Inconsistency between rockspec filename (42fm1b3d7iv6fcbhgm9674as3jh6y2sh-luv-1.22.0-1.rockspec) and its contents (luv-1.22.0-1.rockspec)
|
||||
rockspecFilename="$TMP/$(stripHash ''${knownRockspec})"
|
||||
cp ''${knownRockspec} "$rockspecFilename"
|
||||
''
|
||||
+ ''
|
||||
runHook postConfigure
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
nix_debug "Using LUAROCKS_CONFIG=$LUAROCKS_CONFIG"
|
||||
|
||||
LUAROCKS=${lua.pkgs.luarocks}/bin/luarocks
|
||||
if (( ''${NIX_DEBUG:-0} >= 1 )); then
|
||||
LUAROCKS="$LUAROCKS --verbose"
|
||||
fi
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
postFixup = lib.optionalString (!dontWrapLuaPrograms) ''
|
||||
wrapLuaPrograms
|
||||
'' + attrs.postFixup or "";
|
||||
|
||||
installPhase = attrs.installPhase or ''
|
||||
runHook preInstall
|
||||
|
||||
# work around failing luarocks test for Write access
|
||||
mkdir -p $out
|
||||
|
||||
# luarocks make assumes sources are available in cwd
|
||||
# After the build is complete, it also installs the rock.
|
||||
# If no argument is given, it looks for a rockspec in the current directory
|
||||
# but some packages have several rockspecs in their source directory so
|
||||
# we force the use of the upper level since it is
|
||||
# the sole rockspec in that folder
|
||||
# maybe we could reestablish dependency checking via passing --rock-trees
|
||||
|
||||
nix_debug "ROCKSPEC $rockspecFilename"
|
||||
nix_debug "cwd: $PWD"
|
||||
$LUAROCKS make --deps-mode=all --tree=$out ''${rockspecFilename}
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
|
||||
checkPhase = attrs.checkPhase or ''
|
||||
runHook preCheck
|
||||
$LUAROCKS test
|
||||
runHook postCheck
|
||||
'';
|
||||
|
||||
passthru = {
|
||||
inherit lua; # The lua interpreter
|
||||
inherit externalDeps;
|
||||
inherit luarocks_content;
|
||||
} // passthru;
|
||||
|
||||
meta = {
|
||||
platforms = lua.meta.platforms;
|
||||
# add extra maintainer(s) to every package
|
||||
maintainers = (meta.maintainers or []) ++ [ ];
|
||||
broken = disabled;
|
||||
} // meta;
|
||||
}));
|
||||
in
|
||||
luarocksDrv
|
||||
61
pkgs/development/interpreters/lua-5/default.nix
Normal file
61
pkgs/development/interpreters/lua-5/default.nix
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
# similar to interpreters/python/default.nix
|
||||
{ stdenv, lib, callPackage, fetchurl, fetchpatch, makeBinaryWrapper }:
|
||||
|
||||
rec {
|
||||
lua5_4 = callPackage ./interpreter.nix {
|
||||
sourceVersion = { major = "5"; minor = "4"; patch = "3"; };
|
||||
hash = "1yxvjvnbg4nyrdv10bq42gz6dr66pyan28lgzfygqfwy2rv24qgq";
|
||||
makeWrapper = makeBinaryWrapper;
|
||||
|
||||
patches = lib.optional stdenv.isDarwin ./5.4.darwin.patch;
|
||||
};
|
||||
|
||||
lua5_4_compat = lua5_4.override({
|
||||
compat = true;
|
||||
});
|
||||
|
||||
lua5_3 = callPackage ./interpreter.nix {
|
||||
sourceVersion = { major = "5"; minor = "3"; patch = "6"; };
|
||||
hash = "0q3d8qhd7p0b7a4mh9g7fxqksqfs6mr1nav74vq26qvkp2dxcpzw";
|
||||
makeWrapper = makeBinaryWrapper;
|
||||
|
||||
patches =
|
||||
lib.optionals stdenv.isDarwin [ ./5.2.darwin.patch ];
|
||||
};
|
||||
|
||||
lua5_3_compat = lua5_3.override({
|
||||
compat = true;
|
||||
});
|
||||
|
||||
|
||||
lua5_2 = callPackage ./interpreter.nix {
|
||||
sourceVersion = { major = "5"; minor = "2"; patch = "4"; };
|
||||
hash = "0jwznq0l8qg9wh5grwg07b5cy3lzngvl5m2nl1ikp6vqssmf9qmr";
|
||||
makeWrapper = makeBinaryWrapper;
|
||||
patches = lib.optional stdenv.isDarwin ./5.2.darwin.patch;
|
||||
};
|
||||
|
||||
lua5_2_compat = lua5_2.override({
|
||||
compat = true;
|
||||
});
|
||||
|
||||
|
||||
lua5_1 = callPackage ./interpreter.nix {
|
||||
sourceVersion = { major = "5"; minor = "1"; patch = "5"; };
|
||||
hash = "2640fc56a795f29d28ef15e13c34a47e223960b0240e8cb0a82d9b0738695333";
|
||||
makeWrapper = makeBinaryWrapper;
|
||||
patches = (lib.optional stdenv.isDarwin ./5.1.darwin.patch)
|
||||
++ [ ./CVE-2014-5461.patch ];
|
||||
};
|
||||
|
||||
luajit_2_0 = import ../luajit/2.0.nix {
|
||||
self = luajit_2_0;
|
||||
inherit callPackage lib;
|
||||
};
|
||||
|
||||
luajit_2_1 = import ../luajit/2.1.nix {
|
||||
self = luajit_2_1;
|
||||
inherit callPackage;
|
||||
};
|
||||
|
||||
}
|
||||
27
pkgs/development/interpreters/lua-5/hooks/default.nix
Normal file
27
pkgs/development/interpreters/lua-5/hooks/default.nix
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
# Hooks for building lua packages.
|
||||
{ lua
|
||||
, lib
|
||||
, makeSetupHook
|
||||
, findutils
|
||||
, runCommand
|
||||
}:
|
||||
|
||||
let
|
||||
callPackage = lua.pkgs.callPackage;
|
||||
luaInterpreter = lua.interpreter;
|
||||
in {
|
||||
|
||||
lua-setup-hook = LuaPathSearchPaths: LuaCPathSearchPaths:
|
||||
let
|
||||
hook = ./setup-hook.sh;
|
||||
in runCommand "lua-setup-hook.sh" {
|
||||
# hum doesn't seem to like caps !! BUG ?
|
||||
luapathsearchpaths=lib.escapeShellArgs LuaPathSearchPaths;
|
||||
luacpathsearchpaths=lib.escapeShellArgs LuaCPathSearchPaths;
|
||||
} ''
|
||||
cp ${hook} hook.sh
|
||||
substituteAllInPlace hook.sh
|
||||
mv hook.sh $out
|
||||
'';
|
||||
|
||||
}
|
||||
47
pkgs/development/interpreters/lua-5/hooks/setup-hook.sh
Normal file
47
pkgs/development/interpreters/lua-5/hooks/setup-hook.sh
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
# set -e
|
||||
|
||||
nix_print() {
|
||||
if [ ${NIX_DEBUG:-0} -ge $1 ]; then
|
||||
echo "$2"
|
||||
fi
|
||||
}
|
||||
|
||||
nix_debug() {
|
||||
nix_print 3 "$1"
|
||||
}
|
||||
|
||||
addToLuaSearchPathWithCustomDelimiter() {
|
||||
local varName="$1"
|
||||
local absPattern="$2"
|
||||
# delete longest match starting from the lua placeholder '?'
|
||||
local topDir="${absPattern%%\?*}"
|
||||
|
||||
# export only if the folder exists else LUA_PATH/LUA_CPATH grow too large
|
||||
if [[ ! -d "$topDir" ]]; then return; fi
|
||||
|
||||
# export only if we haven't already got this dir in the search path
|
||||
if [[ ${!varName-} == *"$absPattern"* ]]; then return; fi
|
||||
|
||||
export "${varName}=${!varName:+${!varName};}${absPattern}"
|
||||
}
|
||||
|
||||
addToLuaPath() {
|
||||
local dir="$1"
|
||||
|
||||
if [[ ! -d "$dir" ]]; then
|
||||
nix_debug "$dir not a directory abort"
|
||||
return 0
|
||||
fi
|
||||
cd "$dir"
|
||||
for pattern in @luapathsearchpaths@; do
|
||||
addToLuaSearchPathWithCustomDelimiter LUA_PATH "$PWD/$pattern"
|
||||
done
|
||||
|
||||
# LUA_CPATH
|
||||
for pattern in @luacpathsearchpaths@; do
|
||||
addToLuaSearchPathWithCustomDelimiter LUA_CPATH "$PWD/$pattern"
|
||||
done
|
||||
cd - >/dev/null
|
||||
}
|
||||
|
||||
addEnvHooks "$hostOffset" addToLuaPath
|
||||
152
pkgs/development/interpreters/lua-5/interpreter.nix
Normal file
152
pkgs/development/interpreters/lua-5/interpreter.nix
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
{ lib, stdenv, fetchurl, readline
|
||||
, compat ? false
|
||||
, callPackage
|
||||
, makeWrapper
|
||||
, packageOverrides ? (final: prev: {})
|
||||
, sourceVersion
|
||||
, hash
|
||||
, patches ? []
|
||||
, postConfigure ? null
|
||||
, postBuild ? null
|
||||
, staticOnly ? stdenv.hostPlatform.isStatic
|
||||
}:
|
||||
let
|
||||
luaPackages = callPackage ../../lua-modules {
|
||||
lua = self;
|
||||
overrides = packageOverrides;
|
||||
};
|
||||
|
||||
plat = if (stdenv.isLinux && lib.versionOlder self.luaversion "5.4") then "linux"
|
||||
else if (stdenv.isLinux && lib.versionAtLeast self.luaversion "5.4") then "linux-readline"
|
||||
else if stdenv.isDarwin then "macosx"
|
||||
else if stdenv.hostPlatform.isMinGW then "mingw"
|
||||
else if stdenv.isFreeBSD then "freebsd"
|
||||
else if stdenv.isSunOS then "solaris"
|
||||
else if stdenv.hostPlatform.isBSD then "bsd"
|
||||
else if stdenv.hostPlatform.isUnix then "posix"
|
||||
else "generic";
|
||||
|
||||
self = stdenv.mkDerivation rec {
|
||||
pname = "lua";
|
||||
luaversion = with sourceVersion; "${major}.${minor}";
|
||||
version = "${luaversion}.${sourceVersion.patch}";
|
||||
|
||||
src = fetchurl {
|
||||
url = "https://www.lua.org/ftp/${pname}-${version}.tar.gz";
|
||||
sha256 = hash;
|
||||
};
|
||||
|
||||
LuaPathSearchPaths = luaPackages.lib.luaPathList;
|
||||
LuaCPathSearchPaths = luaPackages.lib.luaCPathList;
|
||||
setupHook = luaPackages.lua-setup-hook LuaPathSearchPaths LuaCPathSearchPaths;
|
||||
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
buildInputs = [ readline ];
|
||||
|
||||
inherit patches;
|
||||
|
||||
# we can't pass flags to the lua makefile because for portability, everything is hardcoded
|
||||
postPatch = ''
|
||||
{
|
||||
echo -e '
|
||||
#undef LUA_PATH_DEFAULT
|
||||
#define LUA_PATH_DEFAULT "./share/lua/${luaversion}/?.lua;./?.lua;./?/init.lua"
|
||||
#undef LUA_CPATH_DEFAULT
|
||||
#define LUA_CPATH_DEFAULT "./lib/lua/${luaversion}/?.so;./?.so;./lib/lua/${luaversion}/loadall.so"
|
||||
'
|
||||
} >> src/luaconf.h
|
||||
'' + lib.optionalString (!stdenv.isDarwin && !staticOnly) ''
|
||||
# Add a target for a shared library to the Makefile.
|
||||
sed -e '1s/^/LUA_SO = liblua.so/' \
|
||||
-e 's/ALL_T *= */&$(LUA_SO) /' \
|
||||
-i src/Makefile
|
||||
cat ${./lua-dso.make} >> src/Makefile
|
||||
'' ;
|
||||
|
||||
# see configurePhase for additional flags (with space)
|
||||
makeFlags = [
|
||||
"INSTALL_TOP=${placeholder "out"}"
|
||||
"INSTALL_MAN=${placeholder "out"}/share/man/man1"
|
||||
"R=${version}"
|
||||
"LDFLAGS=-fPIC"
|
||||
"V=${luaversion}"
|
||||
"PLAT=${plat}"
|
||||
"CC=${stdenv.cc.targetPrefix}cc"
|
||||
"RANLIB=${stdenv.cc.targetPrefix}ranlib"
|
||||
# Lua links with readline wich depends on ncurses. For some reason when
|
||||
# building pkgsStatic.lua it fails because symbols from ncurses are not
|
||||
# found. Adding ncurses here fixes the problem.
|
||||
"MYLIBS=-lncurses"
|
||||
];
|
||||
|
||||
configurePhase = ''
|
||||
runHook preConfigure
|
||||
|
||||
makeFlagsArray+=(CFLAGS='-O2 -fPIC${lib.optionalString compat " -DLUA_COMPAT_ALL"} $(${
|
||||
if lib.versionAtLeast luaversion "5.2" then "SYSCFLAGS" else "MYCFLAGS"})' )
|
||||
makeFlagsArray+=(${lib.optionalString stdenv.isDarwin "CC=\"$CC\""}${lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform) " 'AR=${stdenv.cc.targetPrefix}ar rcu'"})
|
||||
|
||||
installFlagsArray=( TO_BIN="lua luac" INSTALL_DATA='cp -d' \
|
||||
TO_LIB="${if stdenv.isDarwin then "liblua.${version}.dylib"
|
||||
else ("liblua.a" + lib.optionalString (!staticOnly) " liblua.so liblua.so.${luaversion} liblua.so.${version}" )}" )
|
||||
|
||||
runHook postConfigure
|
||||
'';
|
||||
inherit postConfigure;
|
||||
|
||||
inherit postBuild;
|
||||
|
||||
postInstall = ''
|
||||
mkdir -p "$out/share/doc/lua" "$out/lib/pkgconfig"
|
||||
mv "doc/"*.{gif,png,css,html} "$out/share/doc/lua/"
|
||||
rmdir $out/{share,lib}/lua/${luaversion} $out/{share,lib}/lua
|
||||
mkdir -p "$out/lib/pkgconfig"
|
||||
|
||||
cat >"$out/lib/pkgconfig/lua.pc" <<EOF
|
||||
prefix=$out
|
||||
libdir=$out/lib
|
||||
includedir=$out/include
|
||||
INSTALL_BIN=$out/bin
|
||||
INSTALL_INC=$out/include
|
||||
INSTALL_LIB=$out/lib
|
||||
INSTALL_MAN=$out/man/man1
|
||||
|
||||
Name: Lua
|
||||
Description: An Extensible Extension Language
|
||||
Version: ${version}
|
||||
Requires:
|
||||
Libs: -L$out/lib -llua
|
||||
Cflags: -I$out/include
|
||||
EOF
|
||||
ln -s "$out/lib/pkgconfig/lua.pc" "$out/lib/pkgconfig/lua-${luaversion}.pc"
|
||||
ln -s "$out/lib/pkgconfig/lua.pc" "$out/lib/pkgconfig/lua${luaversion}.pc"
|
||||
ln -s "$out/lib/pkgconfig/lua.pc" "$out/lib/pkgconfig/lua${lib.replaceStrings [ "." ] [ "" ] luaversion}.pc"
|
||||
'';
|
||||
|
||||
passthru = rec {
|
||||
buildEnv = callPackage ./wrapper.nix {
|
||||
lua = self;
|
||||
inherit makeWrapper;
|
||||
inherit (luaPackages) requiredLuaModules;
|
||||
};
|
||||
withPackages = import ./with-packages.nix { inherit buildEnv luaPackages;};
|
||||
pkgs = luaPackages;
|
||||
interpreter = "${self}/bin/lua";
|
||||
};
|
||||
|
||||
meta = {
|
||||
homepage = "http://www.lua.org";
|
||||
description = "Powerful, fast, lightweight, embeddable scripting language";
|
||||
longDescription = ''
|
||||
Lua combines simple procedural syntax with powerful data
|
||||
description constructs based on associative arrays and extensible
|
||||
semantics. Lua is dynamically typed, runs by interpreting bytecode
|
||||
for a register-based virtual machine, and has automatic memory
|
||||
management with incremental garbage collection, making it ideal
|
||||
for configuration, scripting, and rapid prototyping.
|
||||
'';
|
||||
license = lib.licenses.mit;
|
||||
platforms = lib.platforms.unix;
|
||||
};
|
||||
};
|
||||
in self
|
||||
4
pkgs/development/interpreters/lua-5/lua-dso.make
Normal file
4
pkgs/development/interpreters/lua-5/lua-dso.make
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
$(LUA_SO): $(CORE_O) $(LIB_O)
|
||||
$(CC) -shared $(LIBS) -Wl,-soname,$(LUA_SO).$(V) -o $@.$(R) $? $(MYLDFLAGS)
|
||||
ln -sf $(LUA_SO).$(R) $(LUA_SO).$(V)
|
||||
ln -sf $(LUA_SO).$(R) $(LUA_SO)
|
||||
4
pkgs/development/interpreters/lua-5/with-packages.nix
Normal file
4
pkgs/development/interpreters/lua-5/with-packages.nix
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
{ buildEnv, luaPackages }:
|
||||
|
||||
# this is a function that returns a function that returns an environment
|
||||
f: let packages = f luaPackages; in buildEnv.override { extraLibs = packages; }
|
||||
16
pkgs/development/interpreters/lua-5/wrap-lua.nix
Normal file
16
pkgs/development/interpreters/lua-5/wrap-lua.nix
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{ lib
|
||||
, lua
|
||||
, makeSetupHook
|
||||
, makeWrapper
|
||||
}:
|
||||
|
||||
# defined in trivial-builders.nix
|
||||
# imported as wrapLua in lua-packages.nix and passed to build-lua-derivation to be used as buildInput
|
||||
makeSetupHook {
|
||||
deps = makeWrapper;
|
||||
substitutions.executable = lua.interpreter;
|
||||
substitutions.lua = lua;
|
||||
substitutions.LuaPathSearchPaths = lib.escapeShellArgs lua.LuaPathSearchPaths;
|
||||
substitutions.LuaCPathSearchPaths = lib.escapeShellArgs lua.LuaPathSearchPaths;
|
||||
} ./wrap.sh
|
||||
|
||||
98
pkgs/development/interpreters/lua-5/wrap.sh
Normal file
98
pkgs/development/interpreters/lua-5/wrap.sh
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
# Inspired by python/wrapper.nix
|
||||
# Wrapper around wrapLuaProgramsIn, below. The $luaPath
|
||||
# variable is passed in from the buildLuarocksPackage function.
|
||||
set -e
|
||||
|
||||
wrapLuaPrograms() {
|
||||
wrapLuaProgramsIn "$out/bin" "$out $luaPath"
|
||||
}
|
||||
|
||||
# Builds environment variables like LUA_PATH and PATH walking through closure
|
||||
# of dependencies.
|
||||
buildLuaPath() {
|
||||
local luaPath="$1"
|
||||
local path
|
||||
|
||||
# Create an empty table of paths (see doc on loadFromPropagatedInputs
|
||||
# for how this is used). Build up the program_PATH and program_LUA_PATH
|
||||
# variables.
|
||||
declare -A luaPathsSeen=()
|
||||
program_PATH=
|
||||
luaPathsSeen["@lua@"]=1
|
||||
addToSearchPath program_PATH @lua@/bin
|
||||
for path in $luaPath; do
|
||||
addToLuaPath "$path"
|
||||
done
|
||||
}
|
||||
|
||||
# with an executable shell script which will set some environment variables
|
||||
# and then call into the original binary (which has been given a .wrapped suffix).
|
||||
# luaPath is a list of directories
|
||||
wrapLuaProgramsIn() {
|
||||
local dir="$1"
|
||||
local luaPath="$2"
|
||||
local f
|
||||
|
||||
buildLuaPath "$luaPath"
|
||||
|
||||
if [ ! -d "$dir" ]; then
|
||||
nix_debug "$dir not a directory"
|
||||
return
|
||||
fi
|
||||
|
||||
nix_debug "wrapping programs in [$dir]"
|
||||
|
||||
# Find all regular files in the output directory that are executable.
|
||||
find "$dir" -type f -perm -0100 -print0 | while read -d "" f; do
|
||||
# Rewrite "#! .../env lua" to "#! /nix/store/.../lua".
|
||||
# Strip suffix, like "3" or "2.7m" -- we don't have any choice on which
|
||||
# Lua to use besides one with this hook anyway.
|
||||
if head -n1 "$f" | grep -q '#!.*/env.*\(lua\)'; then
|
||||
sed -i "$f" -e "1 s^.*/env[ ]*\(lua\)[^ ]*^#! @executable@^"
|
||||
fi
|
||||
|
||||
# wrapProgram creates the executable shell script described
|
||||
# above. The script will set LUA_(C)PATH and PATH variables!
|
||||
# (see pkgs/build-support/setup-hooks/make-wrapper.sh)
|
||||
local -a wrap_args=("$f"
|
||||
--prefix PATH ':' "$program_PATH"
|
||||
--prefix LUA_PATH ';' "$LUA_PATH"
|
||||
--prefix LUA_CPATH ';' "$LUA_CPATH"
|
||||
)
|
||||
|
||||
# Add any additional arguments provided by makeWrapperArgs
|
||||
# argument to buildLuaPackage.
|
||||
# makeWrapperArgs
|
||||
local -a user_args="($makeWrapperArgs)"
|
||||
local -a wrapProgramArgs=("${wrap_args[@]}" "${user_args[@]}")
|
||||
|
||||
# see setup-hooks/make-wrapper.sh
|
||||
wrapProgram "${wrapProgramArgs[@]}"
|
||||
|
||||
done
|
||||
}
|
||||
|
||||
# Adds the lib and bin directories to the LUA_PATH and PATH variables,
|
||||
# respectively. Recurses on any paths declared in
|
||||
# `propagated-native-build-inputs`, while avoiding duplicating paths by
|
||||
# flagging the directories it has visited in `luaPathsSeen`.
|
||||
loadFromPropagatedInputs() {
|
||||
local dir="$1"
|
||||
# Stop if we've already visited here.
|
||||
if [ -n "${luaPathsSeen[$dir]}" ]; then
|
||||
return
|
||||
fi
|
||||
luaPathsSeen[$dir]=1
|
||||
|
||||
addToLuaPath "$dir"
|
||||
addToSearchPath program_PATH $dir/bin
|
||||
|
||||
# Inspect the propagated inputs (if they exist) and recur on them.
|
||||
local prop="$dir/nix-support/propagated-native-build-inputs"
|
||||
if [ -e "$prop" ]; then
|
||||
local new_path
|
||||
for new_path in $(cat $prop); do
|
||||
loadFromPropagatedInputs "$new_path"
|
||||
done
|
||||
fi
|
||||
}
|
||||
76
pkgs/development/interpreters/lua-5/wrapper.nix
Normal file
76
pkgs/development/interpreters/lua-5/wrapper.nix
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
{ lib, stdenv, lua, buildEnv, makeWrapper
|
||||
, extraLibs ? []
|
||||
, extraOutputsToInstall ? []
|
||||
, postBuild ? ""
|
||||
, ignoreCollisions ? false
|
||||
, requiredLuaModules
|
||||
, makeWrapperArgs ? []
|
||||
}:
|
||||
|
||||
# Create a lua executable that knows about additional packages.
|
||||
let
|
||||
env = let
|
||||
paths = requiredLuaModules (extraLibs ++ [ lua ] );
|
||||
in buildEnv {
|
||||
name = "${lua.name}-env";
|
||||
|
||||
inherit paths;
|
||||
inherit ignoreCollisions;
|
||||
extraOutputsToInstall = [ "out" ] ++ extraOutputsToInstall;
|
||||
|
||||
nativeBuildInputs = [
|
||||
makeWrapper
|
||||
(lua.pkgs.lua-setup-hook lua.LuaPathSearchPaths lua.LuaCPathSearchPaths)
|
||||
];
|
||||
|
||||
# we create wrapper for the binaries in the different packages
|
||||
postBuild = ''
|
||||
if [ -L "$out/bin" ]; then
|
||||
unlink "$out/bin"
|
||||
fi
|
||||
mkdir -p "$out/bin"
|
||||
|
||||
addToLuaPath "$out"
|
||||
|
||||
# take every binary from lua packages and put them into the env
|
||||
for path in ${lib.concatStringsSep " " paths}; do
|
||||
nix_debug "looking for binaries in path = $path"
|
||||
if [ -d "$path/bin" ]; then
|
||||
cd "$path/bin"
|
||||
for prg in *; do
|
||||
if [ -f "$prg" ]; then
|
||||
rm -f "$out/bin/$prg"
|
||||
if [ -x "$prg" ]; then
|
||||
nix_debug "Making wrapper $prg"
|
||||
makeWrapper "$path/bin/$prg" "$out/bin/$prg" \
|
||||
--set-default LUA_PATH ";;" \
|
||||
--suffix LUA_PATH ';' "$LUA_PATH" \
|
||||
--set-default LUA_CPATH ";;" \
|
||||
--suffix LUA_CPATH ';' "$LUA_CPATH" \
|
||||
${lib.concatStringsSep " " makeWrapperArgs}
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
done
|
||||
'' + postBuild;
|
||||
|
||||
inherit (lua) meta;
|
||||
|
||||
passthru = lua.passthru // {
|
||||
interpreter = "${env}/bin/lua";
|
||||
inherit lua;
|
||||
env = stdenv.mkDerivation {
|
||||
name = "interactive-${lua.name}-environment";
|
||||
nativeBuildInputs = [ env ];
|
||||
|
||||
buildCommand = ''
|
||||
echo >&2 ""
|
||||
echo >&2 "*** lua 'env' attributes are intended for interactive nix-shell sessions, not for building! ***"
|
||||
echo >&2 ""
|
||||
exit 1
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
in env
|
||||
23
pkgs/development/interpreters/lua-5/zip.patch
Normal file
23
pkgs/development/interpreters/lua-5/zip.patch
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
--- a/Makefile 2007-10-30 01:59:10.000000000 +0300
|
||||
+++ b/Makefile 2014-09-18 11:04:53.176320021 +0400
|
||||
@@ -6,10 +6,6 @@
|
||||
|
||||
include $(CONFIG)
|
||||
|
||||
-ifeq "$(LUA_VERSION_NUM)" "500"
|
||||
-COMPAT_O= $(COMPAT_DIR)/compat-5.1.o
|
||||
-endif
|
||||
-
|
||||
SRCS= src/lua$T.c
|
||||
OBJS= src/lua$T.o $(COMPAT_O)
|
||||
|
||||
@@ -19,9 +15,6 @@
|
||||
src/$(LIBNAME): $(OBJS)
|
||||
export MACOSX_DEPLOYMENT_TARGET="10.3"; $(CC) $(CFLAGS) $(LIB_OPTION) -o src/$(LIBNAME) $(OBJS) -lzzip
|
||||
|
||||
-$(COMPAT_DIR)/compat-5.1.o: $(COMPAT_DIR)/compat-5.1.c
|
||||
- $(CC) -c $(CFLAGS) -o $@ $(COMPAT_DIR)/compat-5.1.c
|
||||
-
|
||||
install: src/$(LIBNAME)
|
||||
mkdir -p $(LUA_LIBDIR)
|
||||
cp src/$(LIBNAME) $(LUA_LIBDIR)
|
||||
Loading…
Add table
Add a link
Reference in a new issue