{ config, pkgs, lib, ... }: with lib; { config = # TODO: create drivers in both the first and second level inits { hardware.genode.platform.policies = let mkPolicy = { name, platformPolicy }: pkgs.writeText "${name}.policy.dhall" ''${platformPolicy} "${name}"''; childPolicies = builtins.concatLists (lib.attrsets.mapAttrsToList (child: childAttrs: lib.attrsets.mapAttrsToList (uplink: uplinkAttrs: mkPolicy { name = "${child}-${uplink}-driver"; inherit (uplinkAttrs) platformPolicy; }) childAttrs.uplinks) config.genode.core.children); in childPolicies; genode.core.supportChildren = let mkUplinkDriver = { name, policyPrefix, driver, verbose }: { package = with pkgs.genodePackages; { ipxe = ipxe_nic_drv; virtio = virtio_nic_drv; }.${driver}; configFile = pkgs.writeText "${name}.dhall" '' let Sigil = env:DHALL_SIGIL let Init = Sigil.Init in λ(binary : Text) → Init.Child.flat Init.Child.Attributes::{ , binary , resources = Init.Resources::{ caps = 128, ram = Sigil.units.MiB 4 } , routes = [ Init.ServiceRoute.parent "IO_MEM" ] , config = Init.Config::{ , attributes = toMap { verbose = "${ if verbose then "yes" else "no" }" } , policies = [ Init.Config.Policy::{ , service = "Nic" , label = Init.LabelSelector.prefix "${policyPrefix}" } ] } } ''; }; mkUplinkDump = { name, childName, policyPrefix }: { package = pkgs.genodePackages.nic_dump; configFile = pkgs.writeText "${name}.dhall" '' let Sigil = env:DHALL_SIGIL let Init = Sigil.Init in λ(binary : Text) → Init.Child.flat Init.Child.Attributes::{ , binary , resources = Init.Resources::{ caps = 128, ram = Sigil.units.MiB 6 } , config = Init.Config::{ , attributes = toMap { downlink = "${childName}", uplink = "driver" } , policies = [ Init.Config.Policy::{ , service = "Nic" , label = Init.LabelSelector.prefix "${policyPrefix}" } ] } } ''; }; otherDrivers = lib.lists.flatten (lib.attrsets.mapAttrsToList (childName: { uplinks, ... }: lib.attrsets.mapAttrsToList (uplink: let childLabel = "${childName} -> ${uplink}"; driverName = "${childName}-${uplink}-driver"; dumpName = "${childName}-${uplink}-dump"; in { driver, dump, verbose, ... }: [(rec { name = driverName; value = mkUplinkDriver { inherit name driver verbose; policyPrefix = if dump then dumpName else childLabel; }; })] ++ lib.lists.optional dump (rec { name = dumpName; value = mkUplinkDump { inherit name childName; policyPrefix = childLabel; }; })) uplinks) config.genode.core.children); in builtins.listToAttrs otherDrivers; }; }