2
0
Fork 0

WiP NixOS host test

This commit is contained in:
Ehmry - 2020-06-20 22:11:52 +05:30
parent 44184862cc
commit 033d6283cf
5 changed files with 149 additions and 3 deletions

View File

@ -157,7 +157,7 @@
];
};
in import ./tests {
inherit self;
inherit self localSystem;
apps = self.apps.${system};
localPackages = nixpkgsFor.${localSystem};
genodepkgs = self.packages.${system};

View File

@ -278,6 +278,8 @@
};
genodeGuests = import ./nixos-host.nix { inherit self; };
workman-layout.genode.inputFilter.extraChargen =
"${./dhall/workman.chargen.dhall}";

View File

@ -0,0 +1,92 @@
# SPDX-License-Identifier: CC0-1.0
{ self }:
{ config, pkgs, lib, ... }:
{
options.genodeGuests = with lib;
let
genodeOpts = { ... }: {
options = {
name = mkOption {
example = "webserver";
type = types.str;
description = "Name of the Genode subsystem.";
};
config = mkOption {
type = types.str;
default = "<config/>";
description = ''
Configuration of the Genode subsystem.
Must be rendered in the Genode XML format.
'';
};
rom = mkOption {
default = pkgs: { };
description = ''
Function taking a package set and returning an attrset of name to store
path mappings. Note that this set is the Nixpkgs collection, the native
Genode packages are found within this set at "genodePackages".
'';
example = literalExample ''
pkgs: {
nic_drv = "${pkgs.genodePackages.linux_nic_drv}/bin/linux_nic_drv";
}
'';
};
};
};
in mkOption {
type = with lib.types; loaOf (submodule genodeOpts);
default = { };
example = {
foobar = {
config = "<empty/>";
rom = pkgs: { };
};
};
description = "Configurations of Genode subsystems.";
};
config = let
crossSystem = config.nixpkgs.localSystem.system + "-"
+ pkgs.targetPlatform.platform.kernelArch + "-genode";
crossPkgs = builtins.trace crossSystem self.legacyPackages.${crossSystem};
in {
systemd.services = let
inherit (crossPkgs.genodePackages) base-linux;
toService = name: cfg: {
description = "Genode subsystem";
wantedBy = [ "multi-user.target" ];
preStart = let
rom' = with crossPkgs.genodePackages;
{
core = "${base-linux}/bin/core-linux";
init = "${init}/bin/init";
"ld.lib.so" = "${base-linux}/bin/ld.lib.so";
timer = "${base-linux}/bin/linux_timer_drv";
config = builtins.toFile "${name}.config.xml" cfg.config;
} // (cfg.rom crossPkgs);
in builtins.concatStringsSep "\n"
(lib.mapAttrsToList (name: value: "ln -s ${value} ${name}") rom');
serviceConfig = {
DynamicUser = true;
RuntimeDirectory = "genode/" + name;
WorkingDirectory = "/run/genode/" + name;
ExecStart = "${base-linux}/bin/core-linux";
};
};
in lib.mapAttrs toService config.genodeGuests;
};
}

View File

@ -1,6 +1,7 @@
# SPDX-License-Identifier: CC0-1.0
{ self, apps, localPackages, genodepkgs, lib, nixpkgs, legacyPackages }:
{ self, localSystem, apps, localPackages, genodepkgs, lib, nixpkgs
, legacyPackages }:
let
@ -282,7 +283,10 @@ let
in lib.lists.crossLists f [ cores' testFiles ];
in builtins.listToAttrs (builtins.filter (_: _ != null) testList)
in builtins.listToAttrs (builtins.filter (_: _ != null) testList) // {
nixos-host =
import ./nixos-host.nix { inherit self localSystem legacyPackages; };
}
/* sotest = let
hwTests = with hw; [ multi posix x86 ];

48
tests/nixos-host.nix Normal file
View File

@ -0,0 +1,48 @@
{ self, localSystem, legacyPackages }:
import "${self.inputs.nixpkgs}/nixos/tests/make-test-python.nix"
({ pkgs, ... }: {
name = "genode-guest";
# meta.maintainers = [ pkgs.lib.maintainers.ehmry ];
machine = {
imports = [ self.nixosModules.genodeGuests ];
genodeGuests.signal-test = {
config = ''
<config>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="RM"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<default-route>
<any-service> <parent/> <any-child/> </any-service>
</default-route>
<default caps="100"/>
<start name="timer" caps="96">
<resource name="RAM" quantum="1M"/>
<provides><service name="Timer"/></provides>
</start>
<start name="test-signal" caps="500">
<resource name="RAM" quantum="10M"/>
</start>
</config>
'';
rom = pkgs: {
"test-signal" =
"${pkgs.genodeSources.depot "test-signal"}/bin/test-signal";
};
};
};
testScript = ''
start_all()
machine.wait_for_unit("genode")
machine.wait_for_open_port("1965")
'';
}) {
system = localSystem;
pkgs = legacyPackages.buildPackages;
}