2024-06-29 21:59:27 +00:00
|
|
|
{ lib
|
2023-07-04 21:58:51 +00:00
|
|
|
, lua
|
2024-04-24 17:30:34 +00:00
|
|
|
, lualinux
|
2023-07-04 21:58:51 +00:00
|
|
|
, writeScriptBin
|
|
|
|
, linotify
|
|
|
|
, anoia
|
2024-03-04 22:47:56 +00:00
|
|
|
, netlink-lua
|
2023-07-04 21:58:51 +00:00
|
|
|
, fennel
|
|
|
|
}:
|
|
|
|
let packages = [
|
|
|
|
linotify
|
|
|
|
anoia
|
|
|
|
fennel
|
2024-04-24 17:30:34 +00:00
|
|
|
lualinux
|
2024-03-04 22:47:56 +00:00
|
|
|
netlink-lua
|
2024-04-24 17:28:39 +00:00
|
|
|
lua.pkgs.readline
|
2023-07-04 21:58:51 +00:00
|
|
|
];
|
|
|
|
join = ps: builtins.concatStringsSep ";" ps;
|
2023-07-08 22:05:00 +00:00
|
|
|
luapath = join (builtins.map (f:
|
|
|
|
"${f}/share/lua/${lua.luaversion}/?.lua;" +
|
|
|
|
"${f}/share/lua/${lua.luaversion}/?/init.lua"
|
|
|
|
) packages);
|
2023-07-04 21:58:51 +00: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"
|
2024-08-24 20:50:30 +00:00
|
|
|
local specials = require("fennel.specials")
|
2023-09-08 23:11:35 +00:00
|
|
|
table.insert(package.loaders or package.searchers,1, fennel.searcher)
|
2024-04-20 13:59:14 +00:00
|
|
|
fennel['macro-path'] = "${anoia.dev}/share/lua/${lua.luaversion}/?.fnl;" .. fennel['macro-path']
|
2023-09-08 23:11:35 +00:00
|
|
|
|
2024-08-24 20:50:30 +00:00
|
|
|
local function eval_as_test(f)
|
|
|
|
local g = (specials["make-compiler-env"]())._G
|
|
|
|
g["RUNNING_TESTS"] = true
|
|
|
|
return fennel.dofile(f, {correlate = true, compilerEnv = g})
|
|
|
|
end
|
|
|
|
|
2023-07-04 21:58:51 +00:00
|
|
|
local more_fennel = os.getenv("FENNEL_PATH")
|
|
|
|
if more_fennel then
|
2024-08-24 20:50:30 +00:00
|
|
|
fennel.path = more_fennel .. ";" .. fennel.path
|
2023-07-04 21:58:51 +00:00
|
|
|
end
|
2023-07-08 21:14:40 +00:00
|
|
|
if #arg > 0 then
|
2024-08-24 20:50:30 +00:00
|
|
|
if arg[1] == '--test' then
|
|
|
|
eval_as_test(arg[2])
|
|
|
|
else
|
|
|
|
script = table.remove(arg, 1)
|
|
|
|
fennel.dofile(script, {correlate = true}, arg)
|
|
|
|
end
|
2023-07-08 21:14:40 +00:00
|
|
|
else
|
2024-08-24 20:50:30 +00:00
|
|
|
fennel.repl()
|
2023-07-08 21:14:40 +00:00
|
|
|
end
|
2023-07-04 21:58:51 +00:00
|
|
|
''
|