From cb30ce52ebb1530d6d62e3937ac6209c463f2ef2 Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Tue, 30 May 2023 18:20:14 +0100 Subject: [PATCH] rotuer: use writeFennelScript for odhcpc update script --- examples/{udhcp6-script.fnl => odhcp6-script.fnl} | 1 + examples/rotuer.nix | 12 ++++-------- 2 files changed, 5 insertions(+), 8 deletions(-) rename examples/{udhcp6-script.fnl => odhcp6-script.fnl} (96%) diff --git a/examples/udhcp6-script.fnl b/examples/odhcp6-script.fnl similarity index 96% rename from examples/udhcp6-script.fnl rename to examples/odhcp6-script.fnl index cd1c287..d72c678 100644 --- a/examples/udhcp6-script.fnl +++ b/examples/odhcp6-script.fnl @@ -1,4 +1,5 @@ +(os.chdir (os.getenv "SERVICE_STATE")) (fn write-value [name value] (with-open [fout (io.open name :w)] diff --git a/examples/rotuer.nix b/examples/rotuer.nix index c19301c..795b6ee 100644 --- a/examples/rotuer.nix +++ b/examples/rotuer.nix @@ -21,6 +21,7 @@ let dropbear ifwait writeText + writeFennelScript serviceFns; in rec { boot = { @@ -235,18 +236,13 @@ in rec { services.dhcp6 = let name = "dhcp6c.wan"; - luafile = pkgs.runCommand "udhcpc-script" {} '' - ${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} "$@") - ''; + luafile = writeFennelScript "odhcpc-script" [] ./odhcp6-script.fnl; in longrun { inherit name; notification-fd = 10; 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 ];