svc.open accepts a /nix/store folder not an outputs folder
this mostly makes things simpler
This commit is contained in:
parent
f22237a3b3
commit
2b0972ed73
14
NEWS
14
NEWS
@ -156,4 +156,16 @@ https://www.liminix.org/doc/admin.html#updating-an-installed-system
|
|||||||
2024-12-22
|
2024-12-22
|
||||||
|
|
||||||
outputs.zimage is now outputs.kernel.zImage. This is unlikely to
|
outputs.zimage is now outputs.kernel.zImage. This is unlikely to
|
||||||
affect many people at all but I mention it anyway.
|
affect many people at all but I mention it anyway.
|
||||||
|
|
||||||
|
2024-03-11
|
||||||
|
|
||||||
|
The fennel function (svc.open ...) now expects to be given the store
|
||||||
|
directory of a service derivation, not a direct path to the .outputs
|
||||||
|
directory. Thus
|
||||||
|
|
||||||
|
(svc.open "/nix/store/eeeeeeeeeeeeee-hellod")
|
||||||
|
not
|
||||||
|
(svc.open "/nix/store/eeeeeeeeeeeeee-hellod/.outputs")
|
||||||
|
|
||||||
|
This simplifies most extant uses of it
|
||||||
|
@ -49,7 +49,7 @@ let
|
|||||||
(mapAttrs' (n: _: mkSet "ip6" n) zones);
|
(mapAttrs' (n: _: mkSet "ip6" n) zones);
|
||||||
allRules = lib.recursiveUpdate extraRules (lib.recursiveUpdate sets rules);
|
allRules = lib.recursiveUpdate extraRules (lib.recursiveUpdate sets rules);
|
||||||
script = firewallgen "firewall1.nft" allRules;
|
script = firewallgen "firewall1.nft" allRules;
|
||||||
watchArg = z: intfs: map (i: "${z}:${i}/.outputs") intfs;
|
watchArg = z: intfs: map (i: "${z}:${i}") intfs;
|
||||||
name = "firewall";
|
name = "firewall";
|
||||||
service = longrun {
|
service = longrun {
|
||||||
inherit name;
|
inherit name;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
servicedir:=$(shell mktemp -d)
|
servicedir:=$(shell mktemp -d)
|
||||||
|
outputdir:=$(servicedir)/.outputs
|
||||||
|
|
||||||
default: fs.lua init.lua nl.lua svc.lua process.lua net/constants.lua
|
default: fs.lua init.lua nl.lua svc.lua process.lua net/constants.lua
|
||||||
|
|
||||||
@ -9,12 +10,13 @@ check:
|
|||||||
fennel ./run-tests.fnl $(CHECK)
|
fennel ./run-tests.fnl $(CHECK)
|
||||||
fennel test.fnl
|
fennel test.fnl
|
||||||
fennel test-svc.fnl $(servicedir)
|
fennel test-svc.fnl $(servicedir)
|
||||||
test -f $(servicedir)/fish
|
find $(outputdir) -ls
|
||||||
test "`cat $(servicedir)/fish`" = "food"
|
test -f $(outputdir)/fish
|
||||||
test -d $(servicedir)/nested/path
|
test "`cat $(outputdir)/fish`" = "food"
|
||||||
test "`cat $(servicedir)/nested/path/name`" = "value"
|
test -d $(outputdir)/nested/path
|
||||||
test "`cat $(servicedir)/nested/path/complex/attribute`" = "val"
|
test "`cat $(outputdir)/nested/path/name`" = "value"
|
||||||
test "`cat $(servicedir)/nested/path/complex/other`" = "42"
|
test "`cat $(outputdir)/nested/path/complex/attribute`" = "val"
|
||||||
|
test "`cat $(outputdir)/nested/path/complex/other`" = "42"
|
||||||
|
|
||||||
|
|
||||||
net/constants.lua: net/constants.c
|
net/constants.lua: net/constants.c
|
||||||
|
1
pkgs/anoia/example-output/.outputs/array/1
Normal file
1
pkgs/anoia/example-output/.outputs/array/1
Normal file
@ -0,0 +1 @@
|
|||||||
|
cat
|
1
pkgs/anoia/example-output/.outputs/array/2
Normal file
1
pkgs/anoia/example-output/.outputs/array/2
Normal file
@ -0,0 +1 @@
|
|||||||
|
dog
|
1
pkgs/anoia/example-output/.outputs/array/3
Normal file
1
pkgs/anoia/example-output/.outputs/array/3
Normal file
@ -0,0 +1 @@
|
|||||||
|
cow
|
1
pkgs/anoia/example-output/.outputs/array/4
Normal file
1
pkgs/anoia/example-output/.outputs/array/4
Normal file
@ -0,0 +1 @@
|
|||||||
|
sheep
|
@ -1,5 +1,5 @@
|
|||||||
(local inotify (require :inotify))
|
(local inotify (require :inotify))
|
||||||
(local { : file-exists? : dirname } (require :anoia))
|
(local { : file-exists? : dirname : append-path } (require :anoia))
|
||||||
(local { : file-type : dir : mktree &as fs } (require :anoia.fs))
|
(local { : file-type : dir : mktree &as fs } (require :anoia.fs))
|
||||||
|
|
||||||
(fn read-line [name]
|
(fn read-line [name]
|
||||||
@ -25,7 +25,7 @@
|
|||||||
(with-open [f (assert (io.open pathname :w) (.. "can't open " pathname))]
|
(with-open [f (assert (io.open pathname :w) (.. "can't open " pathname))]
|
||||||
(f:write value))
|
(f:write value))
|
||||||
"table" (each [k v (pairs value)]
|
"table" (each [k v (pairs value)]
|
||||||
(write-value (.. pathname "/" k) v))))
|
(write-value (append-path pathname k) v))))
|
||||||
|
|
||||||
(fn read-value [pathname]
|
(fn read-value [pathname]
|
||||||
(case (file-type pathname)
|
(case (file-type pathname)
|
||||||
@ -33,7 +33,7 @@
|
|||||||
:directory
|
:directory
|
||||||
(collect [f (fs.dir pathname)]
|
(collect [f (fs.dir pathname)]
|
||||||
(when (not (or (= f ".") (= f "..")))
|
(when (not (or (= f ".") (= f "..")))
|
||||||
(values f (read-value ( .. pathname "/" f)))))
|
(values f (read-value (append-path pathname f)))))
|
||||||
:file
|
:file
|
||||||
(read-line pathname)
|
(read-line pathname)
|
||||||
:link
|
:link
|
||||||
@ -50,15 +50,17 @@
|
|||||||
|
|
||||||
(fn open [directory]
|
(fn open [directory]
|
||||||
(let [watcher (watch-fsevents directory)
|
(let [watcher (watch-fsevents directory)
|
||||||
has-file? (fn [filename] (file-exists? (.. directory "/" filename)))]
|
has-file? #(file-exists? (append-path directory $1))
|
||||||
|
outputs-dir (append-path directory ".outputs")]
|
||||||
{
|
{
|
||||||
:wait #(watcher:read)
|
:wait #(watcher:read)
|
||||||
:ready? (fn [self]
|
:ready? (fn [self]
|
||||||
(and (has-file? "state") (not (has-file? ".lock"))))
|
(and (has-file? ".outputs/state")
|
||||||
|
(not (has-file? ".outputs/.lock"))))
|
||||||
:output (fn [_ filename new-value]
|
:output (fn [_ filename new-value]
|
||||||
(if new-value
|
(if new-value
|
||||||
(write-value (.. directory "/" filename) new-value)
|
(write-value (append-path outputs-dir filename) new-value)
|
||||||
(read-value (.. directory "/" filename))))
|
(read-value (append-path outputs-dir filename))))
|
||||||
:close #(watcher:close)
|
:close #(watcher:close)
|
||||||
:fileno #(watcher:fileno)
|
:fileno #(watcher:fileno)
|
||||||
: events
|
: events
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
: ipairs
|
: ipairs
|
||||||
:output
|
:output
|
||||||
(fn [service-path path default]
|
(fn [service-path path default]
|
||||||
(let [s (assert (svc.open (.. service-path "/.outputs")))]
|
(let [s (assert (svc.open service-path))]
|
||||||
(or (s:output path) default)))
|
(or (s:output path) default)))
|
||||||
:lua_quote #(string.format "%q" $1)
|
:lua_quote #(string.format "%q" $1)
|
||||||
:json_quote (fn [x] (.. "\"" (json-escape x) "\""))
|
:json_quote (fn [x] (.. "\"" (json-escape x) "\""))
|
||||||
|
@ -71,7 +71,7 @@
|
|||||||
|
|
||||||
(fn open-services [output-references]
|
(fn open-services [output-references]
|
||||||
(collect [s p (pairs output-references)]
|
(collect [s p (pairs output-references)]
|
||||||
(values (svc.open (.. s "/.outputs")) p)))
|
(values (svc.open s) p)))
|
||||||
|
|
||||||
(fn run []
|
(fn run []
|
||||||
(let [trees {}
|
(let [trees {}
|
||||||
|
@ -50,8 +50,7 @@
|
|||||||
|
|
||||||
(fn run []
|
(fn run []
|
||||||
(let [{: out-path : watched-service : path } (parse-args arg)
|
(let [{: out-path : watched-service : path } (parse-args arg)
|
||||||
dir (.. watched-service "/.outputs")
|
service (assert (svc.open watched-service))]
|
||||||
service (assert (svc.open dir))]
|
|
||||||
(accumulate [tree {}
|
(accumulate [tree {}
|
||||||
v (service:events)]
|
v (service:events)]
|
||||||
(write-changes out-path tree (or (service:output path) {})))))
|
(write-changes out-path tree (or (service:output path) {})))))
|
||||||
|
Loading…
Reference in New Issue
Block a user