nixos: add genode.init.children.<…>.binary option

Require that all init children declared by Nix be declared with
an absolute path to the program binary.
This commit is contained in:
Ehmry - 2021-02-16 15:25:30 +01:00
parent cc211e763a
commit 2afd2d08cc
22 changed files with 364 additions and 333 deletions

View File

@ -3,6 +3,11 @@
with lib;
let
localPackages = pkgs.buildPackages;
binary = mkOption {
description = "Program binary for this child.";
type = types.path;
};
coreROMs = mkOption {
type = with types; listOf str;
default = [ ];
@ -12,7 +17,7 @@ let
'';
example = [ "platform_info" ];
};
inputs = mkOption {
extraInputs = mkOption {
description = "List of packages to build a ROM store with.";
default = [ ];
type = types.listOf types.package;
@ -34,19 +39,11 @@ in {
description = "Hardware supported by this core.";
};
basePackages = mkOption {
type = types.listOf types.package;
description = ''
List of packages to make availabe before the Nix store is ready.
These are baked into <option>config.genode.core.image</option>.
'';
};
children = mkOption {
type = with types;
attrsOf (submodule {
options = {
inherit coreROMs inputs;
inherit binary coreROMs extraInputs;
configFile = mkOption {
type = types.path;
description = ''
@ -168,12 +165,12 @@ in {
romDirectories = filterAttrs (_: value: value != null) (mapAttrs
(name: value:
if value.inputs == [ ] then
if value.extraInputs == [ ] then
null
else
pkgs.symlinkJoin {
name = "${name}-rom";
paths = value.inputs;
paths = value.extraInputs;
}) config.genode.init.children);
tarball =
@ -187,141 +184,145 @@ in {
message = "invalid Genode core for this system";
}];
genode.core.basePackages =
lib.optional (config.genode.boot.storeBackend != "memory")
pkgs.genodePackages.part_block;
genode.boot.romModules = let
getBin = name: "${builtins.getAttr name pkgs.genodePackages}/bin/${name}";
in {
cached_fs_rom = getBin "cached_fs_rom";
init = "${pkgs.genodePackages.init}/bin/init";
jitter_sponge = "${pkgs.genodePackages.jitter_sponge}/bin/jitter_sponge";
report_rom = "${pkgs.genodePackages.report_rom}/bin/report_rom";
rtc_drv = "${pkgs.genodePackages.rtc_drv}/bin/rtc_drv";
vfs = "${pkgs.genodePackages.vfs.unpatched}/bin/vfs";
"vfs.lib.so" = "${pkgs.genodePackages.vfs.unpatched}/lib/vfs.lib.so";
};
genode.boot.romModules = with pkgs.genodePackages;
let
getBin = name:
"${builtins.getAttr name pkgs.genodePackages}/bin/${name}";
in {
cached_fs_rom = getBin "cached_fs_rom";
init = "${init}/bin/init";
jitter_sponge = "${jitter_sponge}/bin/jitter_sponge";
report_rom = "${report_rom}/bin/report_rom";
rtc_drv = "${rtc_drv}/bin/rtc_drv";
vfs = "${vfs}/bin/vfs";
"vfs.lib.so" = "${vfs}/lib/vfs.lib.so";
};
genode.core.children =
# Component to steer the main fs to a specific partition
(if config.genode.boot.storeBackend != "memory" then {
part_block.configFile = pkgs.writeText "part_block.dhall" ''
let Genode = env:DHALL_GENODE
let Init = Genode.Init
in Init.Child.flat
Init.Child.Attributes::{
, binary = "${pkgs.genodePackages.part_block}/bin/part_block"
, resources = Init.Resources::{ ram = Genode.units.MiB 8 }
, config = Init.Config::{
, attributes = toMap { ignore_mbr = "yes" }
, policies =
[ Init.Config.Policy::{
, service = "Block"
, label = Init.LabelSelector.prefix "fs"
, attributes = toMap
{ partition = "${
toString config.fileSystems."/".block.partition
}"
, writeable = "yes"
, TODO = "select by partition UUID"
}
}
]
}
}
'';
} else
{ }) // {
fs.configFile = let
vfsConfig = if config.genode.boot.storeBackend == "memory" then ''
VFS.vfs
[ VFS.leafAttrs
"tar"
(toMap { name = "${tarball}" })
]
'' else
let
rumpExt2 = ''
VFS.vfs
[ VFS.leafAttrs
"plugin"
( toMap
{ load = "${pkgs.genodePackages.rump}/lib/vfs_rump.lib.so"
, fs = "ext2fs"
, ram = "12M"
}
)
]
'';
in {
ahci = rumpExt2;
usb = rumpExt2;
}.${config.fileSystems."/".block.driver};
storeResources = let
rumpExt2 =
"Init.Resources::{ caps = 256, ram = Genode.units.MiB 16 }";
in {
fs = rumpExt2;
memory = "Init.Resources.default";
}.${config.genode.boot.storeBackend};
persistencePolicies = lib.mapAttrsToList (name: _: ''
, Init.Config.Policy::{
, service = "File_system"
, label = Genode.Init.LabelSelector.prefix
"nixos -> ${name}"
, attributes = toMap { root = "/services", writeable = "yes" }
}
'') (filterAttrs (_: child: child.fsPersistence)
config.genode.init.children);
fsPolicies = map (name: ''
, Init.Config.Policy::{
, service = "File_system"
, label =
Init.LabelSelector.Type.Partial
{ prefix = Some "nixos -> ${name}", suffix = Some "nix-store" }
, attributes = toMap { root = "/nix/store", writeable = "no" }
}
'') (builtins.attrNames config.genode.init.children);
in pkgs.writeText "fs.dhall" ''
part_block = {
binary = "${pkgs.genodePackages.part_block}/bin/part_block";
configFile = pkgs.writeText "part_block.dhall" ''
let Genode = env:DHALL_GENODE
let Init = Genode.Init
let VFS = Genode.VFS
let persistencePolicies = [ ${
toString persistencePolicies
} ] : List Init.Config.Policy.Type
let fsPolicies = [ ${
toString fsPolicies
} ] : List Init.Config.Policy.Type
in Init.Child.flat
in λ(binary : Text) -> Init.Child.flat
Init.Child.Attributes::{
, binary = "vfs"
, resources = ${storeResources}
, provides = [ "File_system" ]
, binary
, resources = Init.Resources::{ ram = Genode.units.MiB 8 }
, config = Init.Config::{
, content = [ ${vfsConfig} ]
, attributes = toMap { ignore_mbr = "yes" }
, policies =
[ Init.Config.Policy::{
, service = "File_system"
, label = Init.LabelSelector.prefix "store_rom"
, attributes = toMap { root = "/" }
, service = "Block"
, label = Init.LabelSelector.prefix "fs"
, attributes = toMap
{ partition = "${
toString config.fileSystems."/".block.partition
}"
, writeable = "yes"
, TODO = "select by partition UUID"
}
}
] # persistencePolicies # fsPolicies
]
}
}
'';
};
} else
{ }) // {
fs = {
binary = "${pkgs.genodePackages.vfs}/bin/vfs";
configFile = let
vfsConfig = if config.genode.boot.storeBackend == "memory" then ''
VFS.vfs
[ VFS.leafAttrs
"tar"
(toMap { name = "${tarball}" })
]
'' else
let
rumpExt2 = ''
VFS.vfs
[ VFS.leafAttrs
"plugin"
( toMap
{ load = "${pkgs.genodePackages.rump}/lib/vfs_rump.lib.so"
, fs = "ext2fs"
, ram = "12M"
}
)
]
'';
in {
ahci = rumpExt2;
usb = rumpExt2;
}.${config.fileSystems."/".block.driver};
storeResources = let
rumpExt2 =
"Init.Resources::{ caps = 256, ram = Genode.units.MiB 16 }";
in {
fs = rumpExt2;
memory = "Init.Resources.default";
}.${config.genode.boot.storeBackend};
persistencePolicies = lib.mapAttrsToList (name: _: ''
, Init.Config.Policy::{
, service = "File_system"
, label = Genode.Init.LabelSelector.prefix
"nixos -> ${name}"
, attributes = toMap { root = "/services", writeable = "yes" }
}
'') (filterAttrs (_: child: child.fsPersistence)
config.genode.init.children);
fsPolicies = map (name: ''
, Init.Config.Policy::{
, service = "File_system"
, label =
Init.LabelSelector.Type.Partial
{ prefix = Some "nixos -> ${name}", suffix = Some "nix-store" }
, attributes = toMap { root = "/nix/store", writeable = "no" }
}
'') (builtins.attrNames config.genode.init.children);
in pkgs.writeText "fs.dhall" ''
let Genode = env:DHALL_GENODE
let Init = Genode.Init
let VFS = Genode.VFS
let persistencePolicies = [ ${
toString persistencePolicies
} ] : List Init.Config.Policy.Type
let fsPolicies = [ ${
toString fsPolicies
} ] : List Init.Config.Policy.Type
in λ(binary : Text) -> Init.Child.flat
Init.Child.Attributes::{
, binary
, resources = ${storeResources}
, provides = [ "File_system" ]
, config = Init.Config::{
, content = [ ${vfsConfig} ]
, policies =
[ Init.Config.Policy::{
, service = "File_system"
, label = Init.LabelSelector.prefix "store_rom"
, attributes = toMap { root = "/" }
}
] # persistencePolicies # fsPolicies
}
}
'';
};
};
genode.boot.configFile = let
@ -331,7 +332,8 @@ in {
}.${config.genode.boot.storeBackend};
coreInputs = with builtins;
concatMap (getAttr "inputs") (attrValues config.genode.core.children);
concatMap (getAttr "extraInputs")
(attrValues config.genode.core.children);
manifest =
# Manifests are Dhall metadata to be attached to every
@ -339,13 +341,17 @@ in {
# using Dhall expressions. Probably not worth pursuing.
pkgs.writeText "manifest.dhall" (mergeManifests (map addManifest
(with pkgs.genodePackages;
config.genode.core.basePackages ++ storeBackendInputs
++ [ cached_fs_rom jitter_sponge report_rom vfs ] ++ coreInputs))
storeBackendInputs ++ [ cached_fs_rom jitter_sponge report_rom vfs ]
++ coreInputs))
+ lib.optionalString (config.genode.boot.romModules != { }) ''
# [ { mapKey = "romModules", mapValue = [ ${
toString (mapAttrsToList
toString ((mapAttrsToList
(k: v: '', { mapKey = "${k}", mapValue = "${v}" }'')
config.genode.boot.romModules)
config.genode.boot.romModules) ++ (lib.attrsets.mapAttrsToList
(name: value:
''
, { mapKey = "${value.binary}", mapValue = "${value.binary}" }'')
config.genode.core.children))
}] } ]'');
storeRomPolicies = mapAttrsToList
@ -367,7 +373,8 @@ in {
extraCoreChildren = "[ ${
toString (lib.mapAttrsToList (name: value:
'', { mapKey = "${name}", mapValue = ${value.configFile} }'')
''
, { mapKey = "${name}", mapValue = ${value.configFile} "${value.binary}" }'')
config.genode.core.children)
} ]";
@ -404,7 +411,8 @@ in {
}) romDirectories;
configFiles = mapAttrsToList (name: child: {
symlink = "config/${name}.dhall";
object = child.configFile;
object = pkgs.writeText "${name}.dhall"
"${child.configFile} ${child.binary}";
}) config.genode.init.children;
in romDirs ++ configFiles;
compressCommand = "cat";

View File

@ -4,6 +4,11 @@ with lib;
let
cfg = config.genode.init;
binary = mkOption {
description = "Program binary for this child.";
type = types.path;
};
coreROMs = mkOption {
type = with types; listOf str;
default = [ ];
@ -13,7 +18,7 @@ let
'';
example = [ "platform_info" ];
};
inputs = mkOption {
extraInputs = mkOption {
description = "List of packages to build a ROM store with.";
default = [ ];
type = types.listOf types.package;
@ -57,7 +62,7 @@ in {
type = with types;
attrsOf (submodule {
options = {
inherit coreROMs inputs;
inherit binary coreROMs extraInputs;
routeToNics = lib.mkOption {
type = with types; listOf str;
@ -97,7 +102,7 @@ in {
type = with types;
attrsOf (submodule {
options = {
inherit coreROMs inputs;
inherit binary coreROMs extraInputs;
configFile = mkOption {
type = types.path;
description = ''
@ -116,7 +121,7 @@ in {
# TODO: convert the subinits to children
children = mapAttrs (name: value: {
inherit (value) inputs;
inherit (value) extraInputs;
configFile = pkgs.writeText "${name}.child.dhall" ''
let Genode = env:DHALL_GENODE
@ -126,8 +131,8 @@ in {
configFile = let
children =
lib.mapAttrsToList (name: value: ", `${name}` = ${value.configFile}")
children = lib.mapAttrsToList
(name: value: '', `${name}` = ${value.configFile} "${value.binary}"'')
cfg.children;
nicRoutes = lib.mapAttrsToList (child: value:

View File

@ -18,6 +18,7 @@ let routeLogRom =
λ(label : Text) → ServiceRoute.parentLabel "ROM" (Some "log") (Some label)
in λ(params : { fontFile : Text }) →
λ(binary : Text) →
Init.toChild
Init::{
, verbose = True

View File

@ -16,7 +16,7 @@ in {
hardware.genode.framebuffer.enable = cfg.enable;
genode.core.children.nitpicker = mkIf cfg.enable {
inputs = [ pkgs.genodePackages.nitpicker ];
binary = "${pkgs.genodePackages.nitpicker}/bin/nitpicker";
configFile = pkgs.writeText "nitpicker.dhall" ''
let Init = (env:DHALL_GENODE).Init
@ -38,7 +38,8 @@ in {
};
genode.core.children.consoleLog = mkIf cfg.consoleLog.enable {
inputs = with pkgs.genodePackages; [
binary = "${pkgs.genodePackages.init}/bin/init";
extraInputs = with pkgs.genodePackages; [
gui_fb
log_core
libc

View File

@ -5,9 +5,10 @@ let XML = Genode.Prelude.XML
let Init = Genode.Init
in λ(params : { policies : List Init.Config.Policy.Type }) →
λ(binary : Text) →
Init.Child.flat
Init.Child.Attributes::{
, binary = "${pkgs.genodePackages.nitpicker}/bin/nitpicker"
, binary
, resources = Init.Resources::{ ram = Genode.units.MiB 4 }
, config = Init.Config::{
, attributes = toMap

View File

@ -25,15 +25,15 @@ with lib;
'');
genode.core.children.ahci_drv = lib.mkIf cfg.enable {
inputs = [ pkgs.genodePackages.ahci_drv ];
binary = "${pkgs.genodePackages.ahci_drv}/bin/ahci_drv";
configFile = pkgs.writeText "ahci_drv.dhall" ''
let Genode = env:DHALL_GENODE
let Init = Genode.Init
in Init.Child.flat
in λ(binary : Text) -> Init.Child.flat
Init.Child.Attributes::{
, binary = "${pkgs.genodePackages.ahci_drv}/bin/ahci_drv"
, binary
, resources = Init.Resources::{
, caps = 400
, ram = Genode.units.MiB 10

View File

@ -16,13 +16,8 @@ with lib;
config = {
genode.core.basePackages = with pkgs.genodePackages; [
acpi_drv
platform_drv
];
genode.core.children.acpi_drv = {
coreROMs = [ "acpi_drv" ];
binary = "${pkgs.genodePackages.acpi_drv}/bin/acpi_drv";
configFile = pkgs.writeText "acpi_drv.dhall" ''
let Genode = env:DHALL_GENODE
@ -30,26 +25,27 @@ with lib;
let label = λ(_ : Text) { local = _, route = _ }
in Init.Child.flat
Init.Child.Attributes::{
, binary = "${pkgs.genodePackages.acpi_drv}/bin/acpi_drv"
, resources = Init.Resources::{
, caps = 400
, ram = Genode.units.MiB 4
, constrainPhys = True
in λ(binary : Text)
Init.Child.flat
Init.Child.Attributes::{
, binary
, resources = Init.Resources::{
, caps = 400
, ram = Genode.units.MiB 4
, constrainPhys = True
}
, romReports = [ label "acpi", label "smbios_table" ]
, routes =
[ Init.ServiceRoute.parent "IRQ"
, Init.ServiceRoute.parent "IO_MEM"
, Init.ServiceRoute.parent "IO_PORT"
]
}
, romReports = [ label "acpi", label "smbios_table" ]
, routes =
[ Init.ServiceRoute.parent "IRQ"
, Init.ServiceRoute.parent "IO_MEM"
, Init.ServiceRoute.parent "IO_PORT"
]
}
'';
};
genode.core.children.platform_drv = {
coreROMs = [ "platform_drv" ];
binary = "${pkgs.genodePackages.platform_drv}/bin/platform_drv";
configFile = let
policies =
map (policy: ", ${policy}") config.hardware.genode.platform.policies;
@ -58,9 +54,9 @@ with lib;
let Init = Genode.Init
in Init.Child.flat
in λ(binary : Text) -> Init.Child.flat
Init.Child.Attributes::{
, binary = "${pkgs.genodePackages.platform_drv}/bin/platform_drv"
, binary
, resources = Init.Resources::{
, caps = 800
, ram = Genode.units.MiB 4

View File

@ -13,15 +13,13 @@ with lib;
config = {
genode.core.children.fb_drv = mkIf config.hardware.genode.framebuffer.enable
(let
genode.core.children.fb_drv =
mkIf config.hardware.genode.framebuffer.enable {
binary = with pkgs.genodePackages;
{
boot = boot_fb_drv;
vesa = vesa_drv;
}.${config.hardware.genode.framebuffer.driver};
in {
inputs = [ binary ];
configFile = let
binary = with pkgs.genodePackages;
{
@ -31,21 +29,20 @@ with lib;
in builtins.toFile "fb_drv.dhall" ''
let Genode = env:DHALL_GENODE
let XML = Genode.Prelude.XML
let Init = Genode.Init
in Init.Child.flat
Init.Child.Attributes::{
, binary = "${binary}"
, resources = Init.Resources::{ caps = 256, ram = Genode.units.MiB 32 }
, routes =
[ Init.ServiceRoute.parent "IO_MEM"
, Init.ServiceRoute.parent "IO_PORT"
]
}
in λ(binary : Text)
Init.Child.flat
Init.Child.Attributes::{
, binary
, resources = Init.Resources::{ caps = 256, ram = Genode.units.MiB 32 }
, routes =
[ Init.ServiceRoute.parent "IO_MEM"
, Init.ServiceRoute.parent "IO_PORT"
]
}
'';
});
};
};

View File

@ -78,19 +78,12 @@ with lib;
let name' = name + ".driver";
in {
name = name';
value = let
value = {
binary = with pkgs.genodePackages;
{
ipxe = ipxe_nic_drv;
virtio = virtio_nic_drv;
}.${interface.genode.driver};
binaryPath = with pkgs.genodePackages;
{
ipxe = "${ipxe_nic_drv}/bin/ipxe_nic_drv";
virtio = "${virtio_nic_drv}/bin/virtio_nic_drv";
}.${interface.genode.driver};
in {
inputs = [ binary ];
configFile = let
policy = lib.mapAttrsToList (childName: value:
if any (nic: nic == name) value.routeToNics then ''
@ -106,9 +99,9 @@ with lib;
let Init = Genode.Init
in Init.Child.flat
in λ(binary : Text) -> Init.Child.flat
Init.Child.Attributes::{
, binary = "${binaryPath}"
, binary
, resources = Init.Resources::{ caps = 128, ram = Genode.units.MiB 4 }
, routes = [ Init.ServiceRoute.parent "IO_MEM" ]
, config = Init.Config::{
@ -127,11 +120,6 @@ with lib;
let
name' = name + ".sockets";
vfsPlugin = with pkgs.genodePackages;
{
lwip = vfs_lwip;
lxip = vfs_lxip;
}.${interface.genode.stack};
vfsPluginPath = with pkgs.genodePackages;
{
lwip = "${vfs_lwip}/lib/vfs_lwip.lib.so";
lxip = "${vfs_lxip}/lib/vfs_lxip.lib.so";
@ -141,7 +129,7 @@ with lib;
value = if interface.genode.stack == null then
null
else {
inputs = [ vfsPlugin ];
binary = "${pkgs.genodePackages.vfs}/bin/vfs";
routeToNics = [ name ];
configFile = let
ram = {
@ -189,9 +177,9 @@ with lib;
let Init = Genode.Init
in Init.Child.flat
in λ(binary : Text) -> Init.Child.flat
Init.Child.Attributes::{
, binary = "${pkgs.genodePackages.vfs}/bin/vfs"
, binary
, provides = [ "File_system" ]
, resources = Init.Resources::{
, caps = 128

View File

@ -35,7 +35,7 @@ with lib;
'');
genode.init.children.usb_drv = lib.mkIf cfg.enable {
inputs = [ pkgs.genodePackages.usb_drv ];
binary = "${pkgs.genodePackages.usb_drv}/bin/usb_drv";
configFile = let toYesNo = b: if b then "yes" else "no";
in builtins.toFile "usb_drv.dhall" ''
let Genode = env:DHALL_GENODE
@ -44,71 +44,71 @@ with lib;
let Init = Genode.Init
in Init.Child.flat
Init.Child.Attributes::{
, binary = "${pkgs.genodePackages.usb_drv}/bin/usb_drv"
, resources = Init.Resources::{ caps = 256, ram = Genode.units.MiB 12 }
, romReports = let local = "devices" in [ { local, route = local } ]
, routes = [ Init.ServiceRoute.parent "IO_MEM" ]
, config =
let storagePolicy =
Init.Config.Policy::{
, service = "Usb"
, label = Init.LabelSelector.prefix "usb_block_drv"
, attributes = toMap { class = "8" }
, diag = Some True
}
in Init.Config::{
, attributes = toMap
{ ehci = "${toYesNo cfg.ehciSupport}"
, ohci = "${toYesNo cfg.ohciSupport}"
, uhci = "${toYesNo cfg.uhciSupport}"
, xhci = "${toYesNo cfg.xhciSupport}"
in λ(binary : Text)
Init.Child.flat
Init.Child.Attributes::{
, binary
, resources = Init.Resources::{ caps = 256, ram = Genode.units.MiB 12 }
, romReports = let local = "devices" in [ { local, route = local } ]
, routes = [ Init.ServiceRoute.parent "IO_MEM" ]
, config =
let storagePolicy =
Init.Config.Policy::{
, service = "Usb"
, label = Init.LabelSelector.prefix "usb_block_drv"
, attributes = toMap { class = "8" }
, diag = Some True
}
, content =
[ XML.element
{ name = "raw"
, attributes = XML.emptyAttributes
, content =
[ XML.leaf
{ name = "report"
, attributes = toMap { devices = "yes" }
}
, Init.Config.Policy.toXML storagePolicy
]
in Init.Config::{
, attributes = toMap
{ ehci = "${toYesNo cfg.ehciSupport}"
, ohci = "${toYesNo cfg.ohciSupport}"
, uhci = "${toYesNo cfg.uhciSupport}"
, xhci = "${toYesNo cfg.xhciSupport}"
}
]
, policies = [ storagePolicy ]
}
}
, content =
[ XML.element
{ name = "raw"
, attributes = XML.emptyAttributes
, content =
[ XML.leaf
{ name = "report"
, attributes = toMap { devices = "yes" }
}
, Init.Config.Policy.toXML storagePolicy
]
}
]
, policies = [ storagePolicy ]
}
}
'';
};
genode.core.children.usb_block_drv =
mkIf config.hardware.genode.usb.storage.enable {
inputs = [ pkgs.genodePackages.usb_block_drv ];
binary = "${pkgs.genodePackages.usb_block_drv}/bin/usb_block_drv";
configFile = builtins.toFile "usb_block_drv.dhall" ''
let Genode = env:DHALL_GENODE
let XML = Genode.Prelude.XML
let Init = Genode.Init
in Init.Child.flat
Init.Child.Attributes::{
, binary = "${pkgs.genodePackages.usb_block_drv}/bin/usb_block_drv"
, resources = Init.Resources::{ caps = 256, ram = Genode.units.MiB 4 }
, config = Init.Config::{
, attributes = toMap { writeable = "yes" }
, policies =
[ Init.Config.Policy::{
, service = "Block"
, label = Init.LabelSelector.prefix "part_block"
}
]
in λ(binary : Text)
Init.Child.flat
Init.Child.Attributes::{
, binary
, resources = Init.Resources::{ caps = 256, ram = Genode.units.MiB 4 }
, config = Init.Config::{
, attributes = toMap { writeable = "yes" }
, policies =
[ Init.Config.Policy::{
, service = "Block"
, label = Init.LabelSelector.prefix "part_block"
}
]
}
}
}
'';
};

View File

@ -2,8 +2,6 @@ let Genode = env:DHALL_GENODE
let Prelude = Genode.Prelude
let XML = Prelude.XML
let Init = Genode.Init
let Child = Init.Child
@ -85,46 +83,72 @@ in λ ( params
}
, config = Init.Config::{
, policies =
[ Init.Config.Policy::{
, service = "ROM"
, label =
Init.LabelSelector.prefix
"nixos -> /nix/store"
}
]
# ( let Entry = Prelude.Map.Entry Text Text
let directStoreROMs =
Prelude.List.map
Text
Init.Config.Policy.Type
( λ(childName : Text) →
Init.Config.Policy::{
, service = "ROM"
, label =
Init.LabelSelector.Type.Partial
{ prefix = Some
"nixos -> ${childName} -> /nix/store/"
, suffix = None Text
}
, attributes = toMap
{ directory = "/" }
}
)
( Prelude.Map.keys
Text
Init.Child.Type
params.subinit.children
)
in Prelude.List.concatMap
Entry
Init.Config.Policy.Type
( λ(e : Entry) →
[ Init.Config.Policy::{
, service = "ROM"
, label =
Init.LabelSelector.prefix
"nixos -> ${e.mapKey}"
, attributes = toMap
{ directory =
"${e.mapValue}/bin"
}
}
, Init.Config.Policy::{
, service = "ROM"
, label =
Init.LabelSelector.Type.Partial
{ prefix = Some
"nixos -> ${e.mapKey}"
, suffix = Some ".so"
let indirectStoreROMS =
let Entry = Prelude.Map.Entry Text Text
in Prelude.List.concatMap
Entry
Init.Config.Policy.Type
( λ(e : Entry) →
[ Init.Config.Policy::{
, service = "ROM"
, label =
Init.LabelSelector.prefix
"nixos -> ${e.mapKey}"
, attributes = toMap
{ directory =
"${e.mapValue}/bin"
}
, attributes = toMap
{ directory =
"${e.mapValue}/lib"
}
}
]
)
params.storeRomPolicies
)
}
, Init.Config.Policy::{
, service = "ROM"
, label =
Init.LabelSelector.Type.Partial
{ prefix = Some
"nixos -> ${e.mapKey}"
, suffix = Some ".so"
}
, attributes = toMap
{ directory =
"${e.mapValue}/lib"
}
}
]
)
params.storeRomPolicies
in [ Init.Config.Policy::{
, service = "ROM"
, label =
Init.LabelSelector.prefix
"nixos -> /nix/store"
}
]
# directStoreROMs
# indirectStoreROMS
}
}
)

View File

@ -57,8 +57,8 @@ with lib; {
let name' = "services." + name;
in {
name = name';
value = {
inputs = with pkgs;
value = rec {
extraInputs = with pkgs;
with genodePackages; [
bash
cached_fs_rom
@ -68,10 +68,10 @@ with lib; {
vfs_pipe
];
inherit (service.genode) fsPersistence;
binary = builtins.head args;
configFile = let
args = lib.strings.splitString " "
(toString service.serviceConfig.ExecStart);
binary = builtins.head args;
args' = ''[ "${concatStringsSep ''", "'' (builtins.tail args)}" ]'';
# TODO: service.environment;
interface = if service.genode.interface == null then

View File

@ -8,12 +8,12 @@
};
genode.boot.storeBackend = "fs";
genode.init.children.hello = {
binary = "${pkgs.hello}/bin/hello";
configFile = ./hello.dhall;
inputs = [ pkgs.hello ];
};
};
testScript = ''
start_all()
machine.wait_until_serial_output("child \"init\" exited with exit value 0")
machine.wait_until_serial_output("Hello, world!")
'';
}

View File

@ -11,6 +11,7 @@ let Init = Genode.Init
let Child = Init.Child
in λ(params : { bash : Text, coreutils : Text }) →
λ(binary : Text) →
let init =
Init::{
, verbose = True

View File

@ -2,12 +2,13 @@
name = "bash";
machine = { pkgs, ... }: {
genode.init.children.bash = {
binary = "${pkgs.genodePackages.init}/bin/init";
configFile = pkgs.writeText "bash.child.dhall" ''
${
./bash.dhall
} { bash = "${pkgs.bash}", coreutils = "${pkgs.coreutils}" }
'';
inputs = with pkgs.genodePackages; [
extraInputs = with pkgs.genodePackages; [
pkgs.bash
cached_fs_rom
libc

View File

@ -6,13 +6,14 @@ let Child = Init.Child
let Libc = Genode.Libc
in Child.flat
Child.Attributes::{
, binary = "hello"
, exitPropagate = True
, resources = Genode.Init.Resources::{
, caps = 500
, ram = Genode.units.MiB 10
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::{ args = [ "hello" ] }
}
, config = Libc.toConfig Libc::{ args = [ "hello" ] }
}

View File

@ -2,8 +2,8 @@
name = "hello";
machine = { pkgs, ... }: {
genode.init.children.hello = {
binary = "${pkgs.hello}/bin/hello";
configFile = ./hello.dhall;
inputs = [ pkgs.hello ];
};
};
testScript = ''

View File

@ -2,6 +2,7 @@
name = "log";
machine = { pkgs, ... }: {
genode.init.children.log = {
binary = "${pkgs.genodePackages.test-log}/bin/test-log";
configFile = pkgs.writeText "test-log.dhall" ''
let Genode =
env:DHALL_GENODE
@ -9,15 +10,16 @@
let Child = Genode.Init.Child
in Child.flat
Child.Attributes::{
, binary = "${pkgs.genodePackages.test-log}/bin/test-log"
, exitPropagate = True
, resources = Genode.Init.Resources::{
, caps = 500
, ram = Genode.units.MiB 10
in λ(binary : Text)
Child.flat
Child.Attributes::{
, binary
, exitPropagate = True
, resources = Genode.Init.Resources::{
, caps = 500
, ram = Genode.units.MiB 10
}
}
}
'';
};
};

View File

@ -26,7 +26,8 @@ in rec {
${
./posix.dhall
} { bash = \"${bash}\", coreutils = \"${coreutils}\", script = \"${script}\" }'';
inputs = map pkgs.genodeSources.depot [ "libc" "posix" "vfs_pipe" "vfs" ]
extraInputs =
map pkgs.genodeSources.depot [ "libc" "posix" "vfs_pipe" "vfs" ]
++ [ bash ];
extraPaths = [ script ] ++ (with legacyPackages; [ coreutils hello ]);
};

View File

@ -26,7 +26,7 @@
in "${./vmm_arm.dhall} ${guest}";
inputs = with pkgs;
extraInputs = with pkgs;
let
vmm' = genodeSources.buildUpstream {
name = "vmm_arm";

View File

@ -4,10 +4,14 @@ let Init = Genode.Init
let Child = Init.Child
in Child.flat
Child.Attributes::{
, binary = "test-vmm_x86"
, exitPropagate = True
, resources = Init.Resources::{ caps = 2048, ram = Genode.units.MiB 256 }
, routes = [ Genode.Init.ServiceRoute.parent "VM" ]
}
in λ(binary : Text) →
Child.flat
Child.Attributes::{
, binary
, exitPropagate = True
, resources = Init.Resources::{
, caps = 2048
, ram = Genode.units.MiB 256
}
, routes = [ Genode.Init.ServiceRoute.parent "VM" ]
}

View File

@ -5,9 +5,9 @@
all (f: any f specs) [ (spec: spec == "nova") (spec: spec == "x86") ];
machine = { pkgs, ... }: {
genode.init.children.vmm = {
binary = "${pkgs.genodePackages.test-vmm_x86}/bin/test-vmm_x86";
configFile = ./vmm_x86.dhall;
coreROMs = [ "platform_info" ];
inputs = with pkgs.genodePackages; [ test-vmm_x86 ];
};
};
}