Compare commits
3 Commits
fa7e682e87
...
19212b1eeb
Author | SHA1 | Date |
---|---|---|
Daniel Barlow | 19212b1eeb | |
Daniel Barlow | cb30ce52eb | |
Daniel Barlow | fdffdbb22a |
|
@ -80,6 +80,9 @@
|
||||||
inherit (pkgs.pseudofile) dir symlink;
|
inherit (pkgs.pseudofile) dir symlink;
|
||||||
inherit (pkgs.liminix.networking) interface;
|
inherit (pkgs.liminix.networking) interface;
|
||||||
in {
|
in {
|
||||||
|
programs.busybox.options = {
|
||||||
|
FEATURE_DD_IBS_OBS = "y"; # ath10k_cal_data needs skip_bytes,fullblock
|
||||||
|
};
|
||||||
hardware = {
|
hardware = {
|
||||||
defaultOutput = "tftpboot";
|
defaultOutput = "tftpboot";
|
||||||
loadAddress = "0x80060000";
|
loadAddress = "0x80060000";
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
|
|
||||||
|
(os.chdir (os.getenv "SERVICE_STATE"))
|
||||||
|
|
||||||
(fn write-value [name value]
|
(fn write-value [name value]
|
||||||
(with-open [fout (io.open name :w)]
|
(with-open [fout (io.open name :w)]
|
|
@ -21,6 +21,7 @@ let
|
||||||
dropbear
|
dropbear
|
||||||
ifwait
|
ifwait
|
||||||
writeText
|
writeText
|
||||||
|
writeFennelScript
|
||||||
serviceFns;
|
serviceFns;
|
||||||
in rec {
|
in rec {
|
||||||
boot = {
|
boot = {
|
||||||
|
@ -235,18 +236,13 @@ in rec {
|
||||||
services.dhcp6 =
|
services.dhcp6 =
|
||||||
let
|
let
|
||||||
name = "dhcp6c.wan";
|
name = "dhcp6c.wan";
|
||||||
luafile = pkgs.runCommand "udhcpc-script" {} ''
|
luafile = writeFennelScript "odhcpc-script" [] ./odhcp6-script.fnl;
|
||||||
${pkgs.luaSmall.pkgs.fennel}/bin/fennel --compile ${./udhcp6-script.fnl} > $out
|
|
||||||
'';
|
|
||||||
script = pkgs.writeAshScript "dhcp6-notify" {} ''
|
|
||||||
. ${serviceFns}
|
|
||||||
(in_outputs ${name}; ${pkgs.luaSmall}/bin/lua ${luafile} "$@")
|
|
||||||
'';
|
|
||||||
in longrun {
|
in longrun {
|
||||||
inherit name;
|
inherit name;
|
||||||
notification-fd = 10;
|
notification-fd = 10;
|
||||||
run = ''
|
run = ''
|
||||||
${pkgs.odhcp6c}/bin/odhcp6c -s ${script} -e -v -p /run/${name}.pid -P 48 $(output ${services.wan} ifname)
|
export SERVICE_STATE=/run/service-state/${name}
|
||||||
|
${pkgs.odhcp6c}/bin/odhcp6c -s ${luafile} -e -v -p /run/${name}.pid -P 48 $(output ${services.wan} ifname)
|
||||||
)
|
)
|
||||||
'';
|
'';
|
||||||
dependencies = [ services.wan ];
|
dependencies = [ services.wan ];
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
kernel = callPackage ./kernel {};
|
kernel = callPackage ./kernel {};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
writeFennelScript = callPackage ./write-fennel-script {};
|
||||||
writeAshScript = callPackage ./write-ash-script {};
|
writeAshScript = callPackage ./write-ash-script {};
|
||||||
systemconfig = callPackage ./systemconfig {};
|
systemconfig = callPackage ./systemconfig {};
|
||||||
s6-init-bin = callPackage ./s6-init-bin {};
|
s6-init-bin = callPackage ./s6-init-bin {};
|
||||||
|
|
|
@ -1,34 +1,13 @@
|
||||||
{
|
{
|
||||||
luaSmall
|
luaSmall
|
||||||
, netlink-lua
|
, netlink-lua
|
||||||
, stdenv
|
, writeFennelScript
|
||||||
, makeWrapper
|
, runCommand
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
lua = luaSmall;
|
lua = luaSmall;
|
||||||
netlink = netlink-lua.override {inherit lua;};
|
netlink = netlink-lua.override {inherit lua;};
|
||||||
fennel = lua.pkgs.fennel;
|
in runCommand "ifwait" {} ''
|
||||||
in stdenv.mkDerivation rec {
|
mkdir -p $out/bin
|
||||||
pname = "ifwait";
|
cp -p ${writeFennelScript "ifwait" [netlink] ./ifwait.fnl} $out/bin/ifwait
|
||||||
version = "1";
|
''
|
||||||
phases = [ "installPhase" ];
|
|
||||||
|
|
||||||
buildInputs = [ lua netlink ];
|
|
||||||
nativeBuildInputs = [ makeWrapper fennel ];
|
|
||||||
|
|
||||||
LUA_CPATH = "${netlink}/lib/lua/${lua.luaversion}/\?.so"; # for nix-shell
|
|
||||||
|
|
||||||
installPhase = ''
|
|
||||||
mkdir -p $out/bin $out/lib
|
|
||||||
fennel --compile ${./ifwait.fnl} > $out/lib/${pname}.lua
|
|
||||||
|
|
||||||
makeWrapper ${lua}/bin/lua $out/bin/${pname} \
|
|
||||||
--prefix LUA_CPATH ";" ${netlink}/lib/lua/${lua.luaversion}/\?.so \
|
|
||||||
--add-flags $out/lib/${pname}.lua
|
|
||||||
# makeWrapper adds a shebang for bash
|
|
||||||
sed -i -e '1c#!/bin/sh' $out/bin/${pname}
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
|
|
||||||
# to use fennel.view,
|
|
||||||
# --prefix LUA_PATH ";" ${fennel}/share/lua/5.2/\?.lua \
|
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
{
|
||||||
|
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 --compile ${source}
|
||||||
|
) > $out
|
||||||
|
chmod a+x $out
|
||||||
|
''
|
|
@ -5,4 +5,5 @@
|
||||||
pppoe = import ./pppoe/test.nix;
|
pppoe = import ./pppoe/test.nix;
|
||||||
jffs2 = import ./jffs2/test.nix;
|
jffs2 = import ./jffs2/test.nix;
|
||||||
min-copy-closure = import ./min-copy-closure/test.nix;
|
min-copy-closure = import ./min-copy-closure/test.nix;
|
||||||
|
fennel = import ./fennel/test.nix;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
(print "hello")
|
|
@ -0,0 +1,21 @@
|
||||||
|
{
|
||||||
|
liminix
|
||||||
|
, nixpkgs
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
overlay = import "${liminix}/overlay.nix";
|
||||||
|
pkgs = import <nixpkgs> { overlays = [overlay]; };
|
||||||
|
script = pkgs.writeFennelScript "foo" [] ./hello.fnl;
|
||||||
|
inherit (pkgs.luaSmall.pkgs) fifo;
|
||||||
|
netlink = pkgs.netlink-lua.override { lua = pkgs.luaSmall; };
|
||||||
|
script2 = pkgs.writeFennelScript "foo2" [fifo netlink] ./hello.fnl;
|
||||||
|
in pkgs.runCommand "check" {
|
||||||
|
} ''
|
||||||
|
set -e
|
||||||
|
# test that it works
|
||||||
|
test $(${script}) = "hello"
|
||||||
|
# test that lua path, cpath are set
|
||||||
|
grep -q ${fifo}/share/lua/5.3 ${script2}
|
||||||
|
grep -q ${netlink}/lib/lua/5.3 ${script2}
|
||||||
|
date > $out
|
||||||
|
''
|
Loading…
Reference in New Issue