nixos: configure Nic uplinks for genode.init.children
…not just genode.core.children.
This commit is contained in:
parent
4d1d37a1ed
commit
291cde7b4a
|
@ -5,7 +5,7 @@ let
|
|||
localPackages = pkgs.buildPackages;
|
||||
|
||||
children' = config.lib.children.freeze
|
||||
(config.genode.core.children // config.genode.core.supportChildren);
|
||||
(config.genode.core.children // config.genode.core.auxiliaryChildren);
|
||||
|
||||
coreErisCaps = with builtins;
|
||||
let pkgNames = [ "rtc_drv" ];
|
||||
|
@ -22,17 +22,15 @@ let
|
|||
bootConfigFile = let
|
||||
|
||||
storeBackendInputs = {
|
||||
fs = [ ];
|
||||
memory = [ config.system.build.tarball ];
|
||||
net = [ ];
|
||||
}.${config.genode.core.storeBackend};
|
||||
}.${config.genode.core.storeBackend} or [ ];
|
||||
|
||||
coreInputs =
|
||||
# TODO: get rid of this?
|
||||
with builtins;
|
||||
concatMap (getAttr "extraInputs")
|
||||
((attrValues config.genode.core.children)
|
||||
++ (attrValues config.genode.core.supportChildren));
|
||||
++ (attrValues config.genode.core.auxiliaryChildren));
|
||||
|
||||
mergeManifests = inputs:
|
||||
with builtins;
|
||||
|
@ -149,7 +147,7 @@ in {
|
|||
'';
|
||||
};
|
||||
|
||||
supportChildren = config.lib.types.children { extraOptions = { }; } // {
|
||||
auxiliaryChildren = config.lib.types.children { extraOptions = { }; } // {
|
||||
internal = true;
|
||||
description = ''
|
||||
Children added to support other children, such as drivers.
|
||||
|
|
|
@ -5,7 +5,8 @@ with lib;
|
|||
let
|
||||
cfg = config.genode.init;
|
||||
|
||||
children' = config.lib.children.freeze config.genode.init.children;
|
||||
children' = config.lib.children.freeze
|
||||
(config.genode.init.children // config.genode.init.auxiliaryChildren);
|
||||
|
||||
in {
|
||||
|
||||
|
@ -65,6 +66,14 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
auxiliaryChildren = config.lib.types.children { extraOptions = { }; } // {
|
||||
internal = true;
|
||||
description = ''
|
||||
Children added to support other children, such as drivers.
|
||||
Do not manually add children here.
|
||||
'';
|
||||
};
|
||||
|
||||
romModules = mkOption {
|
||||
type = types.attrsOf types.path;
|
||||
default = { };
|
||||
|
|
|
@ -15,6 +15,9 @@ in {
|
|||
};
|
||||
|
||||
config = let
|
||||
deviceManagerEnable = config.hardware.genode.ahci.enable
|
||||
|| config.hardware.genode.usb.enable;
|
||||
|
||||
ahciEris = lib.getEris "bin" pkgs.genodePackages.ahci_drv;
|
||||
partBlockEris = lib.getEris "bin" pkgs.genodePackages.part_block;
|
||||
|
||||
|
@ -121,9 +124,7 @@ in {
|
|||
'';
|
||||
};
|
||||
|
||||
genode.core.children.device_manager = lib.mkIf
|
||||
(config.hardware.genode.ahci.enable
|
||||
|| config.hardware.genode.usb.enable) {
|
||||
genode.core.children.device_manager = lib.mkIf deviceManagerEnable {
|
||||
package = pkgs.genodePackages.device_manager;
|
||||
configFile = pkgs.writeText "device_manager.dhall" ''
|
||||
let Sigil = env:DHALL_SIGIL
|
||||
|
@ -141,7 +142,7 @@ in {
|
|||
'';
|
||||
};
|
||||
|
||||
genode.core.children.drivers = {
|
||||
genode.core.children.drivers = lib.mkIf deviceManagerEnable {
|
||||
package = pkgs.genodePackages.init;
|
||||
extraErisInputs = [ partBlockEris ]
|
||||
++ lib.optional config.hardware.genode.ahci.enable ahciEris
|
||||
|
|
|
@ -13,15 +13,29 @@ with lib;
|
|||
|
||||
config = {
|
||||
|
||||
hardware.genode.platform.policies =
|
||||
lib.optional config.hardware.genode.framebuffer.enable
|
||||
(builtins.toFile ("framebuffer.platform-policy.dhall") ''
|
||||
let Sigil = env:DHALL_SIGIL
|
||||
|
||||
in Sigil.Init.Config.Policy::{
|
||||
, service = "Platform"
|
||||
, label = Sigil.Init.LabelSelector.prefix "fb_drv"
|
||||
, content =
|
||||
[ Sigil.Prelude.XML.leaf
|
||||
{ name = "pci", attributes = toMap { class = "VGA" } }
|
||||
]
|
||||
}
|
||||
'');
|
||||
|
||||
genode.core.children.fb_drv =
|
||||
mkIf config.hardware.genode.framebuffer.enable {
|
||||
configFile = let
|
||||
binary = with pkgs.genodePackages;
|
||||
package = with pkgs.genodePackages;
|
||||
{
|
||||
boot = boot_fb_drv;
|
||||
vesa = vesa_drv;
|
||||
}.${config.hardware.genode.framebuffer.driver};
|
||||
in builtins.toFile "fb_drv.dhall" ''
|
||||
configFile = builtins.toFile "fb_drv.dhall" ''
|
||||
let Sigil = env:DHALL_SIGIL
|
||||
|
||||
let Init = Sigil.Init
|
||||
|
@ -39,6 +53,9 @@ with lib;
|
|||
'';
|
||||
};
|
||||
|
||||
virtualisation.graphics =
|
||||
lib.mkDefault config.hardware.genode.framebuffer.enable;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -1,28 +1,6 @@
|
|||
{ 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
|
||||
|
||||
let
|
||||
mkUplinkDriver = { name, policyPrefix, driver, verbose }: {
|
||||
package = with pkgs.genodePackages;
|
||||
{
|
||||
|
@ -80,7 +58,8 @@ with lib;
|
|||
'';
|
||||
};
|
||||
|
||||
otherDrivers = lib.lists.flatten (lib.attrsets.mapAttrsToList
|
||||
nicDriversFor = children:
|
||||
builtins.listToAttrs (lib.lists.flatten (lib.attrsets.mapAttrsToList
|
||||
(childName:
|
||||
{ uplinks, ... }:
|
||||
lib.attrsets.mapAttrsToList (uplink:
|
||||
|
@ -101,8 +80,53 @@ with lib;
|
|||
inherit name childName;
|
||||
policyPrefix = childLabel;
|
||||
};
|
||||
})) uplinks) config.genode.core.children);
|
||||
})) uplinks) children));
|
||||
|
||||
qemuNicsFor = children:
|
||||
builtins.listToAttrs (lib.lists.flatten (lib.attrsets.mapAttrsToList
|
||||
(childName:
|
||||
{ uplinks, ... }:
|
||||
lib.attrsets.mapAttrsToList (uplink:
|
||||
{ driver, ... }: {
|
||||
name = "${childName}-${uplink}";
|
||||
value = {
|
||||
netdev = {
|
||||
kind = "user";
|
||||
settings = { ipv6 = "off"; };
|
||||
};
|
||||
device = {
|
||||
kind = {
|
||||
ipxe = "e1000";
|
||||
virtio = "virtio";
|
||||
}.${driver};
|
||||
};
|
||||
};
|
||||
}) uplinks) children));
|
||||
|
||||
in {
|
||||
|
||||
config = {
|
||||
hardware.genode.platform.policies = let
|
||||
mkPolicy = { name, platformPolicy }:
|
||||
pkgs.writeText "${name}.policy.dhall" ''${platformPolicy} "${name}"'';
|
||||
|
||||
childPolicies = prefix: children:
|
||||
builtins.concatLists (lib.attrsets.mapAttrsToList (child: childAttrs:
|
||||
lib.attrsets.mapAttrsToList (uplink: uplinkAttrs:
|
||||
mkPolicy {
|
||||
name = "${prefix}${child}-${uplink}-driver";
|
||||
inherit (uplinkAttrs) platformPolicy;
|
||||
}) childAttrs.uplinks) children);
|
||||
|
||||
corePolicies = childPolicies "" config.genode.core.children;
|
||||
initPolicies = childPolicies "nixos -> " config.genode.init.children;
|
||||
in corePolicies ++ initPolicies;
|
||||
|
||||
genode.core.auxiliaryChildren = nicDriversFor config.genode.core.children;
|
||||
genode.init.auxiliaryChildren = nicDriversFor config.genode.init.children;
|
||||
|
||||
virtualisation.qemu.nics =
|
||||
qemuNicsFor (config.genode.core.children // config.genode.init.children);
|
||||
|
||||
in builtins.listToAttrs otherDrivers;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue