2023-07-04 23:58:51 +02:00
|
|
|
{
|
|
|
|
runCommand
|
|
|
|
, runtimeShell
|
|
|
|
, fetchurl
|
|
|
|
, lib
|
|
|
|
, luaPackages
|
|
|
|
, lua
|
|
|
|
, writeScriptBin
|
|
|
|
, linotify
|
|
|
|
, anoia
|
|
|
|
, fennel
|
|
|
|
}:
|
|
|
|
let packages = [
|
|
|
|
linotify
|
|
|
|
anoia
|
|
|
|
fennel
|
2023-09-08 21:47:01 +02:00
|
|
|
lua.pkgs.luafilesystem
|
2023-07-04 23:58:51 +02:00
|
|
|
];
|
|
|
|
join = ps: builtins.concatStringsSep ";" ps;
|
2023-07-09 00:05:00 +02:00
|
|
|
luapath = join (builtins.map (f:
|
|
|
|
"${f}/share/lua/${lua.luaversion}/?.lua;" +
|
|
|
|
"${f}/share/lua/${lua.luaversion}/?/init.lua"
|
|
|
|
) packages);
|
2023-07-04 23:58:51 +02:00
|
|
|
luacpath = join (builtins.map (f: "${f}/lib/lua/${lua.luaversion}/?.so") packages);
|
|
|
|
|
|
|
|
in writeScriptBin "fennelrepl" ''
|
|
|
|
#!${lua}/bin/lua
|
|
|
|
package.path = ${lib.strings.escapeShellArg luapath} .. ";" .. package.path
|
|
|
|
package.cpath = ${lib.strings.escapeShellArg luacpath} .. ";" .. (package.cpath or "")
|
|
|
|
local fennel = require "fennel"
|
2023-09-09 01:11:35 +02:00
|
|
|
table.insert(package.loaders or package.searchers,1, fennel.searcher)
|
|
|
|
|
2023-07-04 23:58:51 +02:00
|
|
|
local more_fennel = os.getenv("FENNEL_PATH")
|
|
|
|
if more_fennel then
|
|
|
|
fennel.path = more_fennel .. ";" .. fennel.path
|
|
|
|
end
|
2023-07-08 23:14:40 +02:00
|
|
|
if #arg > 0 then
|
|
|
|
script = table.remove(arg, 1)
|
2023-09-08 22:02:26 +02:00
|
|
|
fennel.dofile(script, {correlate = true}, arg)
|
2023-07-08 23:14:40 +02:00
|
|
|
else
|
|
|
|
fennel.repl()
|
|
|
|
end
|
2023-07-04 23:58:51 +02:00
|
|
|
''
|