24 lines
747 B
Nim
24 lines
747 B
Nim
# SPDX-FileCopyrightText: ☭ 2022 Emery Hemingway
|
|
# SPDX-License-Identifier: Unlicense
|
|
|
|
import std/[asyncdispatch, os]
|
|
import preserves, syndicate, syndicate/capabilities
|
|
|
|
proc unixSocketPath: string =
|
|
result = getEnv("SYNDICATE_SOCK")
|
|
if result == "":
|
|
result = getEnv("XDG_RUNTIME_DIR", "/run/user/1000") / "dataspace"
|
|
|
|
proc mintCap: SturdyRef =
|
|
var key: array[16, byte]
|
|
mint(key, toPreserve("syndicate", Ref))
|
|
|
|
bootDataspace("main") do (root: Ref; turn: var Turn):
|
|
let label = getAppFilename().extractFilename
|
|
connectUnix(turn, unixSocketPath(), mintCap()) do (turn: var Turn; ds: Ref):
|
|
var a = initRecord[Ref](label, commandLineParams().toPreserve(Ref))
|
|
message(turn, ds, a)
|
|
|
|
for i in 0..7: poll(20)
|
|
# A hack to exit
|