push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View 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)

View 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.${pkgversion}.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.${pkgversion}.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.${pkgversion}.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.${pkgversion}.dylib \
+ -compatibility_version ${pkgversion} -current_version ${pkgversion} \
+ -o liblua.${pkgversion}.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.${pkgversion} $(LIBS)
$(LUAC_T): $(LUAC_O) $(LUA_A)
$(CC) -o $@ $(LDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS)

View 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.${pkgversion}.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.${pkgversion}.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.${pkgversion}.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.${pkgversion}.dylib \
+ -compatibility_version ${pkgversion} -current_version ${pkgversion} \
+ -o liblua.${pkgversion}.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.${pkgversion} $(LIBS)
$(LUAC_T): $(LUAC_O) $(LUA_A)
$(CC) -o $@ $(LDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS)

View 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;

View File

@@ -0,0 +1,10 @@
--- a/src/lparser.c
+++ b/src/lparser.c
@@ -301,6 +301,7 @@
expdesc key;
singlevaraux(fs, ls->envn, var, 1); /* get environment variable */
lua_assert(var->k == VLOCAL || var->k == VUPVAL);
+ luaK_exp2anyregup(fs, var); /* but could be a constant */
codestring(ls, &key, varname); /* key is variable name */
luaK_indexed(fs, var, &key); /* env[varname] */
}

View File

@@ -0,0 +1,258 @@
# Generic builder for lua packages
{
lib,
lua,
wrapLua,
luarocks_bootstrap,
writeTextFile,
# Whether the derivation provides a lua module or not.
luarocksCheckHook,
luaLib,
}:
{
pname,
version,
# we need rockspecVersion to find the .rockspec even when version changes
rockspecVersion ? version,
# by default prefix `name` e.g. "lua5.2-${name}"
namePrefix ? "${lua.pname}${lib.versions.majorMinor lua.version}-",
# Dependencies for building the package
buildInputs ? [ ],
# Dependencies needed for running the checkPhase.
# These are added to nativeBuildInputs when doCheck = true.
nativeCheckInputs ? [ ],
# 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,
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 ? "",
# transparent mapping nix <-> lua used as LUAROCKS_CONFIG
# Refer to https://github.com/luarocks/luarocks/wiki/Config-file-format for specs
luarocksConfig ? { },
# relative to srcRoot, path to the rockspec to use when using rocks
rockspecFilename ? null,
# must be set for packages that don't have a rock
knownRockspec ? null,
...
}@attrs:
# Keep extra attributes from `attrs`, e.g., `patchPhase', etc.
let
# 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";
luarocksDrv = luaLib.toLuaModule (
lua.stdenv.mkDerivation (
self:
attrs
// {
name = namePrefix + self.pname + "-" + self.version;
inherit rockspecVersion;
__structuredAttrs = true;
env = {
LUAROCKS_CONFIG = self.configFile;
}
// attrs.env or { };
generatedRockspecFilename = "./${self.pname}-${self.rockspecVersion}.rockspec";
nativeBuildInputs = [
lua # for lua.h
wrapLua
luarocks_bootstrap
];
inherit
doCheck
extraConfig
rockspecFilename
knownRockspec
externalDeps
nativeCheckInputs
;
buildInputs =
let
# example externalDeps': [ { name = "CRYPTO"; dep = pkgs.openssl; } ]
externalDeps' = lib.filter (dep: !lib.isDerivation dep) self.externalDeps;
in
[ luarocks_bootstrap ]
++ buildInputs
++ lib.optionals self.doCheck ([ luarocksCheckHook ] ++ self.nativeCheckInputs)
++ (map (d: d.dep) externalDeps');
# propagate lua to active setup-hook in nix-shell
propagatedBuildInputs = propagatedBuildInputs ++ [ lua ];
# @-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
rocksSubdir = "${self.pname}-${self.version}-rocks";
configFile = writeTextFile {
name = self.pname + "-luarocks-config.lua";
text = self.luarocks_content;
};
luarocks_content = (lib.generators.toLua { asBindings = true; } self.luarocksConfig) + ''
${self.extraConfig}
'';
# TODO make it the default variable
luarocksConfig =
let
externalDepsGenerated = lib.filter (drv: !drv ? luaModule) (
self.nativeBuildInputs ++ self.propagatedBuildInputs ++ self.buildInputs
);
generatedConfig = luaLib.generateLuarocksConfig {
externalDeps = lib.unique (self.externalDeps ++ externalDepsGenerated);
local_cache = "";
# To prevent collisions when creating environments, we install the rock
# files into per-package subdirectories
rocks_subdir = self.rocksSubdir;
# Filter out the lua derivation itself from the Lua module dependency
# closure, as it doesn't have a rock tree :)
# luaLib.hasLuaModule
requiredLuaRocks = lib.filter luaLib.hasLuaModule (
lua.pkgs.requiredLuaModules (self.nativeBuildInputs ++ self.propagatedBuildInputs)
);
};
luarocksConfig' = lib.recursiveUpdate luarocksConfig (
lib.optionalAttrs (attrs ? extraVariables) (
lib.warn "extraVariables in buildLuarocksPackage is deprecated, use luarocksConfig instead" {
variables = attrs.extraVariables;
}
)
);
in
lib.recursiveUpdate generatedConfig luarocksConfig';
configurePhase = ''
runHook preConfigure
''
+ lib.optionalString (self.rockspecFilename == null) ''
rockspecFilename="${self.generatedRockspecFilename}"
''
+ lib.optionalString (self.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 ${self.knownRockspec})"
cp ${self.knownRockspec} "$rockspecFilename"
''
+ ''
runHook postConfigure
'';
buildPhase = ''
runHook preBuild
source ${lua}/nix-support/utils.sh
nix_debug "Using LUAROCKS_CONFIG=$LUAROCKS_CONFIG"
LUAROCKS_EXTRA_ARGS=""
if (( ''${NIX_DEBUG:-0} >= 1 )); then
LUAROCKS_EXTRA_ARGS=" --verbose"
fi
runHook postBuild
'';
postFixup =
lib.optionalString (!dontWrapLuaPrograms) ''
wrapLuaPrograms
''
+ attrs.postFixup or "";
installPhase = ''
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"
luarocks $LUAROCKS_EXTRA_ARGS make --deps-mode=all --tree=$out ''${rockspecFilename}
runHook postInstall
'';
checkPhase = ''
runHook preCheck
luarocks test
runHook postCheck
'';
shellHook = ''
runHook preShell
export LUAROCKS_CONFIG="$PWD/${luarocks_config}";
runHook postShell
'';
passthru = {
inherit lua;
}
// attrs.passthru or { };
meta = {
platforms = lua.meta.platforms;
# add extra maintainer(s) to every package
maintainers = (attrs.meta.maintainers or [ ]) ++ [ ];
broken = disabled;
}
// attrs.meta or { };
}
)
);
in
luarocksDrv

View File

@@ -0,0 +1,189 @@
# similar to interpreters/python/default.nix
{
stdenv,
config,
lib,
callPackage,
fetchFromGitHub,
fetchurl,
makeBinaryWrapper,
}:
let
# Common passthru for all lua interpreters.
# copied from python
passthruFun =
{
executable,
luaversion,
packageOverrides,
luaOnBuildForBuild,
luaOnBuildForHost,
luaOnBuildForTarget,
luaOnHostForHost,
luaOnTargetForTarget,
luaAttr ? null,
self, # is luaOnHostForTarget
}:
let
luaPackages =
callPackage
# Function that when called
# - imports lua-packages.nix
# - adds spliced package sets to the package set
# - applies overrides from `packageOverrides`
(
{
lua,
overrides,
callPackage,
makeScopeWithSplicing',
}:
let
luaPackagesFun = callPackage ../../../top-level/lua-packages.nix {
lua = self;
};
generatedPackages =
if (builtins.pathExists ../../lua-modules/generated-packages.nix) then
(
final: prev:
callPackage ../../lua-modules/generated-packages.nix { inherit (final) callPackage; } final prev
)
else
(final: prev: { });
overriddenPackages = callPackage ../../lua-modules/overrides.nix { };
otherSplices = {
selfBuildBuild = luaOnBuildForBuild.pkgs;
selfBuildHost = luaOnBuildForHost.pkgs;
selfBuildTarget = luaOnBuildForTarget.pkgs;
selfHostHost = luaOnHostForHost.pkgs;
selfTargetTarget = luaOnTargetForTarget.pkgs or { };
};
aliases =
final: prev:
lib.optionalAttrs config.allowAliases (import ../../lua-modules/aliases.nix lib final prev);
extensions = lib.composeManyExtensions [
aliases
generatedPackages
overriddenPackages
overrides
];
in
makeScopeWithSplicing' {
inherit otherSplices;
f = lib.extends extensions luaPackagesFun;
}
)
{
overrides = packageOverrides;
lua = self;
};
in
rec {
buildEnv = callPackage ./wrapper.nix {
lua = self;
makeWrapper = makeBinaryWrapper;
inherit (luaPackages) requiredLuaModules;
};
withPackages = import ./with-packages.nix { inherit buildEnv luaPackages; };
pkgs = luaPackages;
interpreter = "${self}/bin/${executable}";
inherit executable luaversion;
luaOnBuild = luaOnBuildForHost.override {
inherit packageOverrides;
self = luaOnBuild;
};
tests = callPackage ./tests {
lua = self;
inherit (luaPackages) wrapLua;
};
inherit luaAttr;
};
in
rec {
lua5_4 = callPackage ./interpreter.nix {
self = lua5_4;
version = "5.4.7";
hash = "sha256-n79eKO+GxphY9tPTTszDLpEcGii0Eg/z6EqqcM+/HjA=";
makeWrapper = makeBinaryWrapper;
inherit passthruFun;
patches = lib.optional stdenv.hostPlatform.isDarwin ./5.4.darwin.patch;
};
lua5_4_compat = lua5_4.override {
self = lua5_4_compat;
compat = true;
};
lua5_3 = callPackage ./interpreter.nix {
self = lua5_3;
version = "5.3.6";
hash = "0q3d8qhd7p0b7a4mh9g7fxqksqfs6mr1nav74vq26qvkp2dxcpzw";
makeWrapper = makeBinaryWrapper;
inherit passthruFun;
patches = lib.optionals stdenv.hostPlatform.isDarwin [ ./5.2.darwin.patch ];
};
lua5_3_compat = lua5_3.override {
self = lua5_3_compat;
compat = true;
};
lua5_2 = callPackage ./interpreter.nix {
self = lua5_2;
version = "5.2.4";
hash = "0jwznq0l8qg9wh5grwg07b5cy3lzngvl5m2nl1ikp6vqssmf9qmr";
makeWrapper = makeBinaryWrapper;
inherit passthruFun;
patches = [
./CVE-2022-28805.patch
]
++ lib.optional stdenv.hostPlatform.isDarwin ./5.2.darwin.patch;
};
lua5_2_compat = lua5_2.override {
self = lua5_2_compat;
compat = true;
};
lua5_1 = callPackage ./interpreter.nix {
self = lua5_1;
version = "5.1.5";
hash = "2640fc56a795f29d28ef15e13c34a47e223960b0240e8cb0a82d9b0738695333";
makeWrapper = makeBinaryWrapper;
inherit passthruFun;
patches = (lib.optional stdenv.hostPlatform.isDarwin ./5.1.darwin.patch) ++ [
./CVE-2014-5461.patch
];
};
luajit_2_0 = import ../luajit/2.0.nix {
self = luajit_2_0;
inherit
callPackage
fetchFromGitHub
lib
passthruFun
;
};
luajit_2_1 = import ../luajit/2.1.nix {
self = luajit_2_1;
inherit callPackage fetchFromGitHub passthruFun;
};
luajit_openresty = import ../luajit/openresty.nix {
self = luajit_openresty;
inherit callPackage fetchFromGitHub passthruFun;
};
}

View File

@@ -0,0 +1,26 @@
# Hooks for building lua packages.
{
lua,
makeSetupHook,
}:
let
callPackage = lua.pkgs.callPackage;
in
{
luarocksCheckHook = callPackage (
{ luarocks }:
makeSetupHook {
name = "luarocks-check-hook";
propagatedBuildInputs = [ luarocks ];
} ./luarocks-check-hook.sh
) { };
# luarocks installs data in a non-overridable location. Until a proper luarocks patch,
# we move the files around ourselves
luarocksMoveDataFolder = makeSetupHook {
name = "luarocks-move-rock";
propagatedBuildInputs = [ ];
} ./luarocks-move-data.sh;
}

View File

@@ -0,0 +1,18 @@
# Setup hook for checking whether Python imports succeed
echo "Sourcing luarocks-check-hook.sh"
luarocksCheckPhase () {
echo "Executing luarocksCheckPhase"
runHook preCheck
luarocks test
runHook postCheck
echo "Finished executing luarocksCheckPhase"
}
if [ -z "${dontLuarocksCheck-}" ] && [ -z "${checkPhase-}" ]; then
echo "Using luarocksCheckPhase"
checkPhase+=" luarocksCheckPhase"
fi

View File

@@ -0,0 +1,15 @@
# luarocks installs data in a non-overridable location. Until a proper luarocks patch,
# we move the files around ourselves
echo "Sourcing luarocks-move-data-hook.sh"
luarocksMoveDataHook () {
echo "Executing luarocksMoveDataHook"
if [ -d "$out/$rocksSubdir" ]; then
cp -rfv "$out/$rocksSubdir/$pname/$rockspecVersion/." "$out"
fi
echo "Finished executing luarocksMoveDataHook"
}
echo "Using luarocksMoveDataHook"
preFixupHooks+=(luarocksMoveDataHook)

View File

@@ -0,0 +1,236 @@
{
lib,
stdenv,
fetchurl,
readline,
compat ? false,
makeWrapper,
self,
packageOverrides ? (final: prev: { }),
replaceVars,
pkgsBuildBuild,
pkgsBuildHost,
pkgsBuildTarget,
pkgsHostHost,
pkgsTargetTarget,
version,
hash,
passthruFun,
patches ? [ ],
postConfigure ? null,
postBuild ? null,
staticOnly ? stdenv.hostPlatform.isStatic,
luaAttr ? "lua${lib.versions.major version}_${lib.versions.minor version}",
}@inputs:
stdenv.mkDerivation (
finalAttrs:
let
luaPackages = self.pkgs;
luaversion = lib.versions.majorMinor finalAttrs.version;
plat =
if (stdenv.hostPlatform.isLinux && lib.versionOlder self.luaversion "5.4") then
"linux"
else if (stdenv.hostPlatform.isLinux && lib.versionAtLeast self.luaversion "5.4") then
"linux-readline"
else if stdenv.hostPlatform.isDarwin then
"macosx"
else if stdenv.hostPlatform.isMinGW then
"mingw"
else if stdenv.hostPlatform.isFreeBSD then
"freebsd"
else if stdenv.hostPlatform.isSunOS then
"solaris"
else if stdenv.hostPlatform.isBSD then
"bsd"
else if stdenv.hostPlatform.isUnix then
"posix"
else
"generic";
compatFlags =
if (lib.versionOlder self.luaversion "5.3") then
" -DLUA_COMPAT_ALL"
else if (lib.versionOlder self.luaversion "5.4") then
" -DLUA_COMPAT_5_1 -DLUA_COMPAT_5_2"
else
" -DLUA_COMPAT_5_3";
in
{
pname = "lua";
inherit version;
outputs = [
"out"
"doc"
];
src = fetchurl {
url = "https://www.lua.org/ftp/lua-${finalAttrs.version}.tar.gz";
sha256 = hash;
};
LuaPathSearchPaths = luaPackages.luaLib.luaPathList;
LuaCPathSearchPaths = luaPackages.luaLib.luaCPathList;
setupHook = builtins.toFile "lua-setup-hook" ''
source @out@/nix-support/utils.sh
addEnvHooks "$hostOffset" luaEnvHook
'';
nativeBuildInputs = [ makeWrapper ];
buildInputs = [ readline ];
inherit patches;
postPatch = ''
sed -i "s@#define LUA_ROOT[[:space:]]*\"/usr/local/\"@#define LUA_ROOT \"$out/\"@g" src/luaconf.h
# abort if patching didn't work
grep $out src/luaconf.h
''
+ lib.optionalString (!stdenv.hostPlatform.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
'';
env = {
inherit luaversion;
pkgversion = version;
};
# 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 which 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 compatFlags} $(${
if lib.versionAtLeast luaversion "5.2" then "SYSCFLAGS" else "MYCFLAGS"
})' )
makeFlagsArray+=(${lib.optionalString stdenv.hostPlatform.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.hostPlatform.isDarwin then
"liblua.${finalAttrs.version}.dylib"
else
(
"liblua.a"
+ lib.optionalString (
!staticOnly
) " liblua.so liblua.so.${luaversion} liblua.so.${finalAttrs.version}"
)
}" )
runHook postConfigure
'';
inherit postConfigure;
inherit postBuild;
postInstall = ''
mkdir -p "$out/nix-support" "$out/share/doc/lua" "$out/lib/pkgconfig"
cp ${
replaceVars ./utils.sh {
luapathsearchpaths = lib.escapeShellArgs finalAttrs.LuaPathSearchPaths;
luacpathsearchpaths = lib.escapeShellArgs finalAttrs.LuaCPathSearchPaths;
}
} $out/nix-support/utils.sh
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: ${finalAttrs.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"
# Make documentation outputs of different versions co-installable.
mv $out/share/doc/lua $out/share/doc/lua-${finalAttrs.version}
'';
# copied from python
passthru =
let
# When we override the interpreter we also need to override the spliced versions of the interpreter
inputs' = lib.filterAttrs (n: v: !lib.isDerivation v && n != "passthruFun") inputs;
override =
attr:
let
lua = attr.override (inputs' // { self = lua; });
in
lua;
in
passthruFun rec {
inherit
self
luaversion
packageOverrides
luaAttr
;
executable = "lua";
luaOnBuildForBuild = override pkgsBuildBuild.${luaAttr};
luaOnBuildForHost = override pkgsBuildHost.${luaAttr};
luaOnBuildForTarget = override pkgsBuildTarget.${luaAttr};
luaOnHostForHost = override pkgsHostHost.${luaAttr};
luaOnTargetForTarget = lib.optionalAttrs (lib.hasAttr luaAttr pkgsTargetTarget) (
override pkgsTargetTarget.${luaAttr}
);
};
meta = {
homepage = "https://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.
'';
mainProgram = "lua";
license = lib.licenses.mit;
platforms = lib.platforms.unix;
};
}
)

View 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)

View File

@@ -0,0 +1,21 @@
# Always failing assertion with a message.
#
# Example:
# fail "It should have been but it wasn't to be"
function fail() {
echo -e "$1"
exit 1
}
function assertStringEqual() {
if ! diff <(echo "$1") <(echo "$2") ; then
fail "Actual value: \"$1\"\nExpected value: \"$2\""
fi
}
function assertStringContains() {
if ! echo "$1" | grep -q "$2" ; then
fail "expected \"$1\" to contain \"$2\""
fi
}

View File

@@ -0,0 +1,126 @@
{
lua,
hello,
wrapLua,
lib,
pkgs,
}:
let
runTest =
lua:
{ name, command }:
pkgs.runCommandLocal "test-${lua.name}-${name}"
{
nativeBuildInputs = [ lua ];
meta.platforms = lua.meta.platforms;
}
(
''
source ${./assert.sh}
''
+ command
+ "touch $out"
);
wrappedHello = hello.overrideAttrs (oa: {
propagatedBuildInputs = [
wrapLua
lua.pkgs.cjson
];
postFixup = ''
wrapLuaPrograms
'';
});
luaWithModule = lua.withPackages (ps: [
ps.lua-cjson
]);
golden_LUA_PATHS = {
# Looking at lua interpreter 'setpath' code
# for instance https://github.com/lua/lua/blob/69ea087dff1daba25a2000dfb8f1883c17545b7a/loadlib.c#L599
# replace ";;" by ";LUA_PATH_DEFAULT;"
"5.1" =
";./?.lua;${lua}/share/lua/5.1/?.lua;${lua}/share/lua/5.1/?/init.lua;${lua}/lib/lua/5.1/?.lua;${lua}/lib/lua/5.1/?/init.lua;";
"5.2" =
";${lua}/share/lua/5.2/?.lua;${lua}/share/lua/5.2/?/init.lua;${lua}/lib/lua/5.2/?.lua;${lua}/lib/lua/5.2/?/init.lua;./?.lua;";
"5.3" =
";${lua}/share/lua/5.3/?.lua;${lua}/share/lua/5.3/?/init.lua;${lua}/lib/lua/5.3/?.lua;${lua}/lib/lua/5.3/?/init.lua;./?.lua;./?/init.lua;";
# lua5.4 seems to be smarter about it and dont add the lua separators when nothing left or right
"5.4" =
"${lua}/share/lua/5.4/?.lua;${lua}/share/lua/5.4/?/init.lua;${lua}/lib/lua/5.4/?.lua;${lua}/lib/lua/5.4/?/init.lua;./?.lua;./?/init.lua";
# luajit versions
"2.0" =
";./?.lua;${lua}/share/luajit-2.0/?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua;${lua}/share/lua/5.1/?.lua;${lua}/share/lua/5.1/?/init.lua;";
"2.1" =
";./?.lua;${lua}/share/luajit-2.1/?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua;${lua}/share/lua/5.1/?.lua;${lua}/share/lua/5.1/?/init.lua;";
};
in
pkgs.recurseIntoAttrs {
checkInterpreterPath =
let
golden_LUA_PATH = golden_LUA_PATHS.${lib.versions.majorMinor lua.version};
in
runTest lua {
name = "check-default-lua-path";
command = ''
export LUA_PATH=";;"
generated=$(lua -e 'print(package.path)')
assertStringEqual "$generated" "${golden_LUA_PATH}"
'';
};
checkWrapping = pkgs.runCommandLocal "test-${lua.name}-wrapping" { } ''
grep -- 'LUA_PATH=' ${wrappedHello}/bin/hello
touch $out
'';
# checks that lua's setup-hook adds dependencies to LUA_PATH
# Prevents the following regressions
# $ env NIX_PATH=nixpkgs=. nix-shell --pure -Q -p luajitPackages.lua luajitPackages.http
# nix-shell$ luajit
# > require('http.request')
# stdin:1: module 'http.request' not found:
checkSetupHook =
pkgs.runCommandLocal "test-${lua.name}-setup-hook"
{
nativeBuildInputs = [ lua ];
buildInputs = [ lua.pkgs.http ];
meta.platforms = lua.meta.platforms;
}
''
${lua}/bin/lua -e "require'http.request'"
touch $out
'';
checkRelativeImports = pkgs.runCommandLocal "test-${lua.name}-relative-imports" { } ''
source ${./assert.sh}
lua_vanilla_package_path="$(${lua}/bin/lua -e "print(package.path)")"
lua_with_module_package_path="$(${luaWithModule}/bin/lua -e "print(package.path)")"
assertStringContains "$lua_vanilla_package_path" "./?.lua"
assertStringContains "$lua_vanilla_package_path" "./?/init.lua"
assertStringContains "$lua_with_module_package_path" "./?.lua"
assertStringContains "$lua_with_module_package_path" "./?/init.lua"
touch $out
'';
# Check that a lua package's propagatedBuildInputs end up in LUA_PATH
checkPropagatedBuildInputs =
pkgs.runCommandLocal "test-${lua.name}-setup-hook"
{
buildInputs = [ lua.pkgs.rest-nvim ];
}
# `xml2lua` is a propagatedBuildInput of rest-nvim
''
${lua}/bin/lua -e "require'xml2lua'"
touch $out
'';
}

View File

@@ -0,0 +1,130 @@
#!/bin/bash
declare -gA luaPathsSeen=()
# shellcheck disable=SC2164,SC2041
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"
# export only if we haven't already got this dir in the search path
if [[ ${!varName-} == *"$absPattern"* ]]; then return; fi
# if the path variable has not yet been set, initialize it to ";;"
# this is a magic value that will be replaced by the default,
# allowing relative modules to be used even when there are system modules.
if [[ ! -v "${varName}" ]]; then export "${varName}=;;"; fi
# export only if the folder contains lua files
shopt -s globstar
local adjustedPattern="${absPattern/\?/\*\*\/\*}"
for _file in $adjustedPattern; do
export "${varName}=${!varName:+${!varName};}${absPattern}"
shopt -u globstar
return;
done
shopt -u globstar
}
# used in setup Hooks to load LUA_PATH and LUA_CPATH
# luaEnvHook
luaEnvHook() {
_addToLuaPath "$1"
}
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
}
_addToLuaPath() {
local dir="$1"
nix_debug "_addToLuaPath called for dir $dir"
if [[ ! -d "$dir" ]]; then
nix_debug "$dir not a directory abort"
return 0
fi
# set -x
# if [ -n "${pythonPathsSeen[$dir]}" ]; then return; fi
if [[ -n "${luaPathsSeen[$dir]:-}" ]]; then
# if [ -n "${luaPathsSeen[$dir]}" ]; then
nix_debug "$dir already parsed"
return
fi
luaPathsSeen["$dir"]=true
# shellcheck disable=SC2164
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
addToSearchPath program_PATH "$dir"/bin
# Inspect the propagated inputs (if they exist) and recur on them.
local prop="$dir/nix-support/propagated-build-inputs"
if [ -e "$prop" ]; then
local new_path
for new_path in $(cat $prop); do
nix_debug "newpath: $new_path"
_addToLuaPath "$new_path"
done
fi
}
# Builds environment variables like LUA_PATH and PATH walking through closure
# of dependencies.
buildLuaPath() {
local luaPath="$1"
local path
nix_debug "BUILD_LUA_PATH"
# # Create an empty table of paths (see doc on loadFromPropagatedInputs
# # for how this is used). Build up the program_PATH variable.
# # shellcheck disable=SC2034
program_PATH=
for path in $luaPath; do
_addToLuaPath "$path"
done
}

View File

@@ -0,0 +1,8 @@
{ buildEnv, luaPackages }:
# this is a function that returns a function that returns an environment
f:
let
packages = f luaPackages;
in
buildEnv.override { extraLibs = packages; }

View File

@@ -0,0 +1,14 @@
{
lua,
makeSetupHook,
makeWrapper,
}:
# defined in trivial-builders
# imported as wrapLua in lua-packages.nix and passed to build-lua-derivation to be used as buildInput
makeSetupHook {
name = "wrap-lua-hook";
propagatedBuildInputs = [ makeWrapper ];
substitutions.executable = lua.interpreter;
substitutions.lua = lua;
} ./wrap.sh

View File

@@ -0,0 +1,56 @@
# Inspired by python/wrapper.nix
# Wrapper around wrapLuaProgramsIn, below. The $luaPath
# variable is passed in from the buildLuarocksPackage function.
set -e
source @lua@/nix-support/utils.sh
wrapLuaPrograms() {
wrapLuaProgramsIn "$out/bin" "$out $luaPath"
}
# 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".
# 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
}

View File

@@ -0,0 +1,87 @@
{
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 = [ lua ] ++ requiredLuaModules extraLibs;
in
buildEnv {
name = "${lua.name}-env";
inherit paths;
inherit ignoreCollisions;
extraOutputsToInstall = [ "out" ] ++ extraOutputsToInstall;
nativeBuildInputs = [
makeWrapper
];
# we create wrapper for the binaries in the different packages
postBuild = ''
source ${lua}/nix-support/utils.sh
if [ -L "$out/bin" ]; then
unlink "$out/bin"
fi
mkdir -p "$out/bin"
buildLuaPath "$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;
luaPath = lua.pkgs.luaLib.genLuaPathAbsStr env;
luaCpath = lua.pkgs.luaLib.genLuaCPathAbsStr env;
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

View 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)