sigil/tests/nim.nix

57 lines
1.4 KiB
Nix

{
name = "nim";
machine = { pkgs, lib, ... }: {
genode.init.children.test_nim = let
testNim = with pkgs;
stdenv.mkDerivation {
pname = "test-nim";
inherit (nim-unwrapped) version;
nativeBuildInputs = [ nim ];
dontUnpack = true;
dontConfigure = true;
buildPhase = ''
export HOME=$NIX_BUILD_TOP
cat << EOF > test_nim.nim
echo "Hello Nim world!"
EOF
nim cpp -d:posix -d:release test_nim
'';
installPhase = ''
install -Dt $out/bin test_nim
'';
};
in {
binary = "${testNim}/bin/test_nim";
extraInputs = with pkgs.genodePackages; [ libc stdcxx ];
configFile = builtins.toFile "nim.dhall" ''
let Genode = env:DHALL_GENODE
let Init = Genode.Init
let Child = Init.Child
let Libc = Genode.Libc
in λ(binary : Text)
Child.flat
Child.Attributes::{
, binary
, exitPropagate = True
, resources = Genode.Init.Resources::{
, caps = 500
, ram = Genode.units.MiB 10
}
, config = Libc.toConfig Libc.default
}
'';
};
};
testScript = ''
start_all()
machine.wait_until_serial_output("Hello Nim world!")
'';
}