From 0a737c62cd2fea82787774bcc4bdd1901882ffa7 Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Tue, 12 Sep 2023 17:51:00 +0100 Subject: [PATCH] convert acquire-wan-address to writeFennel this means we can get rid of the inelegant environent variable check at the bottom of the file --- examples/acquire-wan-address.fnl | 11 ++++------- examples/acquire-wan-address.nix | 9 +++++---- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/examples/acquire-wan-address.fnl b/examples/acquire-wan-address.fnl index 68a66ca..faf20d0 100644 --- a/examples/acquire-wan-address.fnl +++ b/examples/acquire-wan-address.fnl @@ -30,8 +30,9 @@ (.. "ip address del " p.address "/" p.len " dev " wan-device))) new-addresses)) -(fn run [state-directory wan-device] - (let [dir (svc.open state-directory)] +(fn run [] + (let [[state-directory wan-device] arg + dir (svc.open state-directory)] (var addresses []) (while true (while (not (dir:ready?)) (dir:wait)) @@ -40,8 +41,4 @@ (update-addresses wan-device addresses (dir:output "address")))) (dir:wait)))) - -(if (os.getenv "RUN_TESTS") - { : update-addresses : changes : run } - (let [[state-directory wan-device] arg] - (run state-directory wan-device))) +{ : update-addresses : changes : run } diff --git a/examples/acquire-wan-address.nix b/examples/acquire-wan-address.nix index df55a54..2039899 100644 --- a/examples/acquire-wan-address.nix +++ b/examples/acquire-wan-address.nix @@ -1,8 +1,9 @@ { - writeFennelScript + writeFennel , linotify , anoia }: -writeFennelScript "acquire-wan-address" - [ linotify anoia ] - ./acquire-wan-address.fnl +writeFennel "acquire-wan-address" { + packages = [ linotify anoia ]; + mainFunction = "run"; +} ./acquire-wan-address.fnl