2023-07-04 23:58:51 +02:00
|
|
|
{
|
|
|
|
runCommand
|
|
|
|
, runtimeShell
|
|
|
|
, fetchurl
|
|
|
|
, lib
|
|
|
|
, luaPackages
|
|
|
|
, lua
|
2024-04-24 19:30:34 +02:00
|
|
|
, lualinux
|
2023-07-04 23:58:51 +02:00
|
|
|
, writeScriptBin
|
|
|
|
, linotify
|
|
|
|
, anoia
|
2024-03-04 23:47:56 +01:00
|
|
|
, netlink-lua
|
2024-09-07 19:41:06 +02:00
|
|
|
, iwinfo
|
2023-07-04 23:58:51 +02:00
|
|
|
, fennel
|
|
|
|
}:
|
|
|
|
let packages = [
|
|
|
|
linotify
|
|
|
|
anoia
|
|
|
|
fennel
|
2024-04-24 19:30:34 +02:00
|
|
|
lualinux
|
2024-03-04 23:47:56 +01:00
|
|
|
netlink-lua
|
2024-09-07 19:41:06 +02:00
|
|
|
iwinfo
|
2024-04-24 19:28:39 +02:00
|
|
|
lua.pkgs.readline
|
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)
|
2024-04-20 15:59:14 +02:00
|
|
|
fennel['macro-path'] = "${anoia.dev}/share/lua/${lua.luaversion}/?.fnl;" .. fennel['macro-path']
|
2023-09-09 01:11:35 +02:00
|
|
|
|
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
|
|
|
''
|