2023-02-25 00:03:09 +01:00
|
|
|
{
|
2023-03-25 00:43:13 +01:00
|
|
|
luaSmall
|
2023-02-25 00:03:09 +01:00
|
|
|
, netlink-lua
|
|
|
|
, stdenv
|
|
|
|
, makeWrapper
|
|
|
|
}:
|
|
|
|
let
|
2023-03-25 00:43:13 +01:00
|
|
|
lua = luaSmall;
|
2023-02-25 00:03:09 +01:00
|
|
|
netlink = netlink-lua.override {inherit lua;};
|
|
|
|
fennel = lua.pkgs.fennel;
|
|
|
|
in stdenv.mkDerivation rec {
|
2023-03-01 18:55:52 +01:00
|
|
|
pname = "ifwait";
|
2023-02-25 00:03:09 +01:00
|
|
|
version = "1";
|
2023-03-01 18:55:52 +01:00
|
|
|
phases = [ "installPhase" ];
|
2023-02-25 00:03:09 +01:00
|
|
|
|
2023-03-01 18:55:52 +01:00
|
|
|
buildInputs = [ lua netlink ];
|
|
|
|
nativeBuildInputs = [ makeWrapper fennel ];
|
2023-02-25 00:03:09 +01:00
|
|
|
|
2023-03-01 18:55:52 +01:00
|
|
|
LUA_CPATH = "${netlink}/lib/lua/${lua.luaversion}/\?.so"; # for nix-shell
|
2023-02-25 00:03:09 +01:00
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/bin $out/lib
|
2023-03-01 18:55:52 +01:00
|
|
|
fennel --compile ${./ifwait.fnl} > $out/lib/${pname}.lua
|
2023-02-25 00:03:09 +01:00
|
|
|
|
|
|
|
makeWrapper ${lua}/bin/lua $out/bin/${pname} \
|
|
|
|
--prefix LUA_CPATH ";" ${netlink}/lib/lua/${lua.luaversion}/\?.so \
|
2023-03-01 18:55:52 +01:00
|
|
|
--add-flags $out/lib/${pname}.lua
|
2023-03-06 18:48:17 +01:00
|
|
|
# makeWrapper adds a shebang for bash
|
|
|
|
sed -i -e '1c#!/bin/sh' $out/bin/${pname}
|
2023-02-25 00:03:09 +01:00
|
|
|
'';
|
|
|
|
}
|
|
|
|
|
|
|
|
# to use fennel.view,
|
|
|
|
# --prefix LUA_PATH ";" ${fennel}/share/lua/5.2/\?.lua \
|