28 lines
841 B
Nim
28 lines
841 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 envStep: Preserve[Ref] =
|
|
var s = getEnv("SYNDICATE_STEP")
|
|
if s != "": parsePreserves(s, Ref)
|
|
else: capabilities.mint().toPreserve(Ref)
|
|
|
|
proc main =
|
|
let label = getAppFilename().extractFilename
|
|
discard bootDataspace(label) do (root: Ref; turn: var Turn):
|
|
let step = envStep()
|
|
connect(turn, unixSocketPath(), step) do (turn: var Turn; ds: Ref):
|
|
message(turn, ds, initRecord(label, map(commandLineParams(), parsePreserves)))
|
|
|
|
for _ in 1..4: poll()
|
|
quit()
|
|
|
|
main()
|