2023-05-29 21:20:12 +02:00
|
|
|
{
|
2023-07-04 23:56:17 +02:00
|
|
|
lua
|
2023-05-29 21:20:12 +02:00
|
|
|
, lib
|
2023-07-04 23:56:17 +02:00
|
|
|
, fennel
|
|
|
|
, stdenv
|
2023-05-29 21:20:12 +02:00
|
|
|
}:
|
2023-07-04 23:56:17 +02:00
|
|
|
name : packages : source :
|
2023-05-29 21:20:12 +02:00
|
|
|
let
|
2023-07-02 19:19:54 +02:00
|
|
|
luapath = builtins.map (f: "${f}/share/lua/${lua.luaversion}/?.lua;") packages;
|
|
|
|
luacpath = builtins.map (f: "${f}/lib/lua/${lua.luaversion}/?.so;") packages;
|
2023-07-04 23:56:17 +02:00
|
|
|
in stdenv.mkDerivation {
|
|
|
|
inherit name;
|
|
|
|
src = ./.;
|
|
|
|
nativeBuildInputs = [ fennel ];
|
|
|
|
buildPhase = ''
|
2023-05-29 21:20:12 +02:00
|
|
|
(
|
2023-07-04 23:56:17 +02:00
|
|
|
echo "#!${lua}/bin/lua"
|
|
|
|
echo "package.path = ${lib.strings.escapeShellArg luapath} .. package.path"
|
|
|
|
echo "package.cpath = ${lib.strings.escapeShellArg luacpath} .. package.cpath"
|
|
|
|
fennel --correlate --compile ${source}
|
|
|
|
) > ${name}.lua
|
|
|
|
'';
|
|
|
|
installPhase = ''
|
|
|
|
cp ${name}.lua $out
|
|
|
|
chmod +x $out
|
|
|
|
'';
|
|
|
|
}
|