22 lines
706 B
Nim
22 lines
706 B
Nim
# SPDX-FileCopyrightText: ☭ Emery Hemingway
|
|
# SPDX-License-Identifier: Unlicense
|
|
|
|
import std/[asyncdispatch, sequtils, os]
|
|
import preserves, syndicate, syndicate/capabilities
|
|
|
|
proc unixSocketPath: Unix =
|
|
result.path = getEnv("SYNDICATE_SOCK")
|
|
if result.path == "":
|
|
result.path = getEnv("XDG_RUNTIME_DIR", "/run/user/1000") / "dataspace"
|
|
|
|
proc main =
|
|
let label = getAppFilename().extractFilename
|
|
bootDataspace(label) do (root: Ref; turn: var Turn):
|
|
connect(turn, unixSocketPath(), capabilities.mint().toPreserve(Ref)) do (turn: var Turn; ds: Ref):
|
|
message(turn, ds, initRecord(label, map(commandLineParams(), parsePreserves)))
|
|
|
|
for i in 0..3: poll(20)
|
|
# A hack to exit
|
|
|
|
main()
|