2023-05-29 21:20:12 +02:00
|
|
|
{
|
|
|
|
runCommand
|
2023-07-02 19:19:54 +02:00
|
|
|
, lua
|
2023-05-29 21:20:12 +02:00
|
|
|
, runtimeShell
|
2023-06-20 21:19:11 +02:00
|
|
|
, fetchurl
|
2023-05-29 21:20:12 +02:00
|
|
|
, lib
|
2023-06-20 21:19:11 +02:00
|
|
|
, lua53Packages
|
2023-05-29 21:20:12 +02:00
|
|
|
}:
|
2023-06-20 21:19:11 +02:00
|
|
|
let inherit (lua53Packages) lua;
|
2023-05-29 21:20:12 +02:00
|
|
|
in name : packages : source :
|
|
|
|
let
|
2023-06-20 21:19:11 +02:00
|
|
|
fennel = fetchurl {
|
|
|
|
url = "https://fennel-lang.org/downloads/fennel-1.3.0";
|
|
|
|
hash = "sha256-hYSD3rBYF8iTjBOA1m+TvUu8BSp8q6uIMUXi0xwo/dU=";
|
|
|
|
};
|
|
|
|
|
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-06-20 21:19:11 +02:00
|
|
|
in runCommand name {
|
|
|
|
nativeBuildInputs = [ lua ];
|
|
|
|
} ''
|
|
|
|
echo $PATH
|
2023-05-29 21:20:12 +02:00
|
|
|
#!${runtimeShell}
|
|
|
|
(
|
2023-07-02 19:19:54 +02:00
|
|
|
echo "#!${lua}/bin/lua"
|
2023-05-29 21:20:12 +02:00
|
|
|
echo "package.path = ${lib.strings.escapeShellArg luapath} .. package.path"
|
|
|
|
echo "package.cpath = ${lib.strings.escapeShellArg luacpath} .. package.cpath"
|
2023-06-20 21:19:11 +02:00
|
|
|
lua ${fennel} --correlate --compile ${source}
|
2023-05-29 21:20:12 +02:00
|
|
|
) > $out
|
|
|
|
chmod a+x $out
|
|
|
|
''
|