liminix/pkgs/write-fennel-script/default.nix
Daniel Barlow 3f4dbfcfd3 ipv6 prefix delegation for rotuer
much tidying needed, but it works
2023-05-31 23:29:05 +01:00

21 lines
641 B
Nix

{
runCommand
, luaSmall
, runtimeShell
, lib
}:
let lua = luaSmall;
in name : packages : source :
let
luapath = builtins.map (f: "${f}/share/lua/${lua.luaversion}/?.lua;") packages;
luacpath = builtins.map (f: "${f}/lib/lua/${lua.luaversion}/?.so;") packages;
in runCommand name {} ''
#!${runtimeShell}
(
echo "#!${lua}/bin/lua"
echo "package.path = ${lib.strings.escapeShellArg luapath} .. package.path"
echo "package.cpath = ${lib.strings.escapeShellArg luacpath} .. package.cpath"
${lua.pkgs.fennel}/bin/fennel --correlate --compile ${source}
) > $out
chmod a+x $out
''