Add syndicate test
This commit is contained in:
parent
23ccb0a30c
commit
ce08351d4d
|
@ -165,23 +165,23 @@ in nullPkgs // {
|
||||||
# Stay clear of upstream on this one.
|
# Stay clear of upstream on this one.
|
||||||
addPatchesHost [ ./ncurses/genode.patch ] prev.ncurses;
|
addPatchesHost [ ./ncurses/genode.patch ] prev.ncurses;
|
||||||
|
|
||||||
nim-unwrapped =
|
nimNoLibs = nim.override { stdenv = stdenvNoLibs; };
|
||||||
# programs are still linking to posix library
|
|
||||||
overrideAttrsTarget ({ patches, ... }: {
|
|
||||||
version = "1.6.8";
|
|
||||||
src = fetchurl {
|
|
||||||
url = "https://nim-lang.org/download/nim-1.6.8.tar.xz";
|
|
||||||
hash = "sha256-D1tlzbYPeK9BywdcI4mDaJoeH34lyBnxeYYsGKSEz1c=";
|
|
||||||
};
|
|
||||||
patches = patches ++ [ ./nim.patch ];
|
|
||||||
}) prev.nim-unwrapped;
|
|
||||||
|
|
||||||
nimPackages =
|
nimPackages =
|
||||||
# Packages from the Nimble flake with adjustments.
|
# Packages from the Nimble flake with adjustments.
|
||||||
prev.nimPackages.overrideScope' (_: prev': {
|
prev.nimPackages.overrideScope' (final': prev':
|
||||||
|
with final'; {
|
||||||
|
buildNimPackage = if hostPlatform.isGenode then
|
||||||
|
({ nimFlags ? [ ], ... }@args:
|
||||||
|
prev'.buildNimPackage (args // {
|
||||||
|
nimBackend = "cpp";
|
||||||
|
nimDefines.posix = { };
|
||||||
|
doCheck = false;
|
||||||
|
}))
|
||||||
|
else
|
||||||
|
prev'.buildNimPackage;
|
||||||
|
|
||||||
dhall = with prev';
|
dhall = buildNimPackage rec {
|
||||||
buildNimPackage rec {
|
|
||||||
pname = "dhall";
|
pname = "dhall";
|
||||||
version = "20221007";
|
version = "20221007";
|
||||||
src = prev.fetchFromSourcehut {
|
src = prev.fetchFromSourcehut {
|
||||||
|
@ -193,16 +193,34 @@ in nullPkgs // {
|
||||||
buildInputs = [ bigints cbor ];
|
buildInputs = [ bigints cbor ];
|
||||||
};
|
};
|
||||||
|
|
||||||
genode = prev'.genode.overrideAttrs (attrs: rec {
|
genode = prev'.genode.overrideAttrs ({ ... }: rec {
|
||||||
version = "20.11.1";
|
version = "20221020";
|
||||||
src = fetchgit {
|
src = final.fetchFromSourcehut {
|
||||||
inherit (attrs.src) url;
|
owner = "~ehmry";
|
||||||
rev = "v${version}";
|
repo = "nim_genode";
|
||||||
sha256 = "0i78idsrgph0g2yir6niar7v827y6qnmd058s6mpvp091sllvlv8";
|
rev = version;
|
||||||
};
|
hash = "sha256-kUbhYKoN/H/fP7ekDYY5rZwZY8UDdcbFBEodthFkmYk=";
|
||||||
});
|
};
|
||||||
|
});
|
||||||
|
|
||||||
});
|
preserves = overrideAttrsTarget ({ ... }: rec {
|
||||||
|
pname = "preserves";
|
||||||
|
version = "20221020";
|
||||||
|
src = final.fetchFromGitea {
|
||||||
|
domain = "git.syndicate-lang.org";
|
||||||
|
owner = "ehmry";
|
||||||
|
repo = "${pname}-nim";
|
||||||
|
rev = version;
|
||||||
|
sha256 = "sha256-yUyt4hAKvEKTFV9KF8994k7RrirQQJ2Jv7ngjbnfXgw=";
|
||||||
|
};
|
||||||
|
dontFixup = true; # this is breaking input propagation?
|
||||||
|
}) prev'.preserves;
|
||||||
|
|
||||||
|
syndicate = overrideAttrsTarget ({ ... }: {
|
||||||
|
dontFixup = true; # this is breaking input propagation?
|
||||||
|
}) prev'.syndicate;
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
openssl =
|
openssl =
|
||||||
overrideHost { static = true; } # shared library comes out stupid big
|
overrideHost { static = true; } # shared library comes out stupid big
|
||||||
|
|
|
@ -16,6 +16,7 @@ let
|
||||||
./hello.nix
|
./hello.nix
|
||||||
./log.nix
|
./log.nix
|
||||||
./nim.nix
|
./nim.nix
|
||||||
|
./syndicate
|
||||||
./tor.nix
|
./tor.nix
|
||||||
./usb.nix
|
./usb.nix
|
||||||
./vmm_x86.nix
|
./vmm_x86.nix
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
{
|
{
|
||||||
name = "nim";
|
name = "nim";
|
||||||
machine = { pkgs, ... }: {
|
machine = { pkgs, ... }: {
|
||||||
genode.init.children.test_nim = let
|
genode.init.children.test_nim = {
|
||||||
testNim = with pkgs;
|
package = with pkgs;
|
||||||
nimPackages.buildNimPackage {
|
nimPackages.buildNimPackage {
|
||||||
pname = "test_nim";
|
pname = "test_nim";
|
||||||
inherit (nim) version;
|
inherit (nim) version;
|
||||||
|
nimDefines.posix = {};
|
||||||
unpackPhase = ''
|
unpackPhase = ''
|
||||||
mkdir test
|
mkdir test
|
||||||
cd test
|
cd test
|
||||||
|
@ -16,8 +17,6 @@
|
||||||
EOF
|
EOF
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
in {
|
|
||||||
package = testNim;
|
|
||||||
configFile = builtins.toFile "nim.dhall" ''
|
configFile = builtins.toFile "nim.dhall" ''
|
||||||
let Sigil = env:DHALL_SIGIL
|
let Sigil = env:DHALL_SIGIL
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
{
|
||||||
|
name = "syndicate";
|
||||||
|
machine = { pkgs, ... }: {
|
||||||
|
genode.init.verbose = true;
|
||||||
|
genode.init.children.syndicate_service = {
|
||||||
|
package = with pkgs.nimPackages;
|
||||||
|
buildNimPackage rec {
|
||||||
|
pname = "syndicate";
|
||||||
|
version = "unstable";
|
||||||
|
nimDefines.posix = { };
|
||||||
|
src = ./src;
|
||||||
|
propagatedBuildInputs = [ genode npeg preserves syndicate ];
|
||||||
|
nimBinOnly = true;
|
||||||
|
meta.mainProgram = "test";
|
||||||
|
};
|
||||||
|
extraInputs = with pkgs.genodePackages; [ libc stdcxx ];
|
||||||
|
configFile = builtins.toFile "nim.dhall" ''
|
||||||
|
let Sigil = env:DHALL_SIGIL
|
||||||
|
|
||||||
|
let Init = Sigil.Init
|
||||||
|
|
||||||
|
let Child = Init.Child
|
||||||
|
|
||||||
|
let Libc = Sigil.Libc
|
||||||
|
|
||||||
|
in λ(binary : Text) →
|
||||||
|
Child.flat
|
||||||
|
Child.Attributes::{
|
||||||
|
, binary
|
||||||
|
, exitPropagate = True
|
||||||
|
, resources = Sigil.Init.Resources::{
|
||||||
|
, caps = 500
|
||||||
|
, ram = Sigil.units.MiB 10
|
||||||
|
}
|
||||||
|
, routes =
|
||||||
|
[ Sigil.Init.ServiceRoute.parentLabel
|
||||||
|
"ROM"
|
||||||
|
(Some "state")
|
||||||
|
(Some "state")
|
||||||
|
]
|
||||||
|
, config =
|
||||||
|
(Libc.toConfig Libc.default)
|
||||||
|
with attributes = toMap { ld_verbose = "true" }
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
testScript = ''
|
||||||
|
start_all()
|
||||||
|
machine.wait_until_serial_output("<ROM \"config\"")
|
||||||
|
'';
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
# SPDX-FileCopyrightText: ☭ 2022 Emery Hemingway
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-or-later.txt
|
||||||
|
|
||||||
|
import std/[asyncdispatch, options, streams, strutils, xmltree]
|
||||||
|
import genode, genode/[reports, roms]
|
||||||
|
import preserves, preserves/xmlhooks, syndicate
|
||||||
|
|
||||||
|
type RomAssertion {.preservesRecord: "ROM".} = object
|
||||||
|
name: string
|
||||||
|
content: XmlNode
|
||||||
|
|
||||||
|
type RomCallback = proc (t: var Turn; rom: RomClient) {.closure, gcsafe.}
|
||||||
|
proc newRomHandler(env: GenodeEnv; label: string; turn: var Turn; cb: RomCallback): RomHandler =
|
||||||
|
## Create a `RomHandler` that dispatches a callback within a Syndicate `Turn`.
|
||||||
|
let facet = turn.facet
|
||||||
|
result = newRomHandler(env, label) do (rom: RomClient):
|
||||||
|
run(facet) do (turn: var Turn):
|
||||||
|
cb(turn, rom)
|
||||||
|
|
||||||
|
componentConstructHook = proc(env: GenodeEnv) =
|
||||||
|
|
||||||
|
bootDataspace("main") do (ds: Ref; turn: var Turn):
|
||||||
|
echo "bootDataspace…"
|
||||||
|
# Syndicate boot hook
|
||||||
|
|
||||||
|
onPublish(turn, ds, grab()) do (a: Assertion):
|
||||||
|
echo "seen in Syndicate dataspace ", ds, " - ", a
|
||||||
|
|
||||||
|
var configHandle, stateHandle: syndicate.Handle
|
||||||
|
let configRom = newRomHandler(env, "config", turn) do (turn: var Turn; rom: RomClient):
|
||||||
|
# config ROM hook
|
||||||
|
var ass = RomAssertion(name: "config", content: rom.xml)
|
||||||
|
echo "publish ", ass.name, " XML in dataspace: ", ass.content
|
||||||
|
replace(turn, ds, configHandle, ass)
|
|
@ -0,0 +1 @@
|
||||||
|
bin = @["test.nim"]
|
Loading…
Reference in New Issue