|
|
|
@ -4,10 +4,10 @@ with lib;
|
|
|
|
|
let
|
|
|
|
|
localPackages = pkgs.buildPackages;
|
|
|
|
|
|
|
|
|
|
children' = config.lib.children.freeze config.genode.init.children;
|
|
|
|
|
children' = config.lib.children.freeze config.genode.core.children;
|
|
|
|
|
|
|
|
|
|
coreErisCaps = with builtins;
|
|
|
|
|
let pkgNames = [ "cached_fs_rom" "jitter_sponge" "rtc_drv" ];
|
|
|
|
|
let pkgNames = [ "rtc_drv" ];
|
|
|
|
|
in listToAttrs (map (name:
|
|
|
|
|
let pkg = pkgs.genodePackages.${name};
|
|
|
|
|
in {
|
|
|
|
@ -18,21 +18,12 @@ let
|
|
|
|
|
tarball =
|
|
|
|
|
"${config.system.build.tarball}/tarball/${config.system.build.tarball.fileName}.tar";
|
|
|
|
|
|
|
|
|
|
/* romDirectories = filterAttrs (_: value: value != null) (mapAttrs (name: value:
|
|
|
|
|
if value.extraInputs == [ ] then
|
|
|
|
|
null
|
|
|
|
|
else
|
|
|
|
|
pkgs.symlinkJoin {
|
|
|
|
|
name = "${name}-rom";
|
|
|
|
|
paths = value.extraInputs;
|
|
|
|
|
}) config.genode.init.children);
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
bootConfigFile = let
|
|
|
|
|
|
|
|
|
|
storeBackendInputs = {
|
|
|
|
|
fs = [ pkgs.genodePackages.rump ];
|
|
|
|
|
fs = [ ];
|
|
|
|
|
memory = [ config.system.build.tarball ];
|
|
|
|
|
net = [ ];
|
|
|
|
|
}.${config.genode.boot.storeBackend};
|
|
|
|
|
|
|
|
|
|
coreInputs = with builtins;
|
|
|
|
@ -50,7 +41,8 @@ let
|
|
|
|
|
}", mapValue = ${input.manifest} }''
|
|
|
|
|
else
|
|
|
|
|
abort "${input.pname} does not have a manifest";
|
|
|
|
|
in (foldl' f "[" inputs) + "]";
|
|
|
|
|
in (foldl' f "([" inputs)
|
|
|
|
|
+ "] : List { mapKey : Text, mapValue : List { mapKey : Text, mapValue : Text } }) ";
|
|
|
|
|
|
|
|
|
|
addManifest = drv:
|
|
|
|
|
drv // {
|
|
|
|
@ -113,11 +105,7 @@ let
|
|
|
|
|
let XML = Genode.Prelude.XML
|
|
|
|
|
in
|
|
|
|
|
${./store-wrapper.dhall}
|
|
|
|
|
{ binaries = {
|
|
|
|
|
, cached_fs_rom = "${cached_fs_rom.cap}"
|
|
|
|
|
, jitter_sponge = "${jitter_sponge.cap}"
|
|
|
|
|
, rtc_drv = "${rtc_drv.cap}"
|
|
|
|
|
}
|
|
|
|
|
{ binaries = { rtc_drv = "${rtc_drv.cap}" }
|
|
|
|
|
, extraCoreChildren = ${extraCoreChildren}
|
|
|
|
|
, subinit = ${config.genode.init.configFile}
|
|
|
|
|
, storeSize = $(stat --format '%s' ${tarball})
|
|
|
|
@ -202,7 +190,7 @@ in {
|
|
|
|
|
type = types.enum [ "fs" "memory" ]; # "parent"?
|
|
|
|
|
default = "memory";
|
|
|
|
|
description = ''
|
|
|
|
|
Backend for the initial /nix/store file-system.
|
|
|
|
|
Backend for the initial ROM store.
|
|
|
|
|
|
|
|
|
|
<variablelist>
|
|
|
|
|
<varlistentry>
|
|
|
|
@ -257,138 +245,30 @@ in {
|
|
|
|
|
"report_rom" = "${pkgs.genodePackages.report_rom}/bin/report_rom";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
genode.core.children =
|
|
|
|
|
# Component to steer the main fs to a specific partition
|
|
|
|
|
(if config.genode.boot.storeBackend != "memory" then {
|
|
|
|
|
part_block = {
|
|
|
|
|
package = pkgs.genodePackages.part_block;
|
|
|
|
|
configFile = pkgs.writeText "part_block.dhall" ''
|
|
|
|
|
let Genode = env:DHALL_GENODE
|
|
|
|
|
|
|
|
|
|
let Init = Genode.Init
|
|
|
|
|
|
|
|
|
|
in λ(binary : Text) -> Init.Child.flat
|
|
|
|
|
Init.Child.Attributes::{
|
|
|
|
|
, binary
|
|
|
|
|
, 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 = {
|
|
|
|
|
package = pkgs.genodePackages.vfs;
|
|
|
|
|
extraErisInputs =
|
|
|
|
|
lib.optional (config.genode.boot.storeBackend == "memory")
|
|
|
|
|
pkg.genodePackages.rump;
|
|
|
|
|
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.core.children.jitter_sponge = {
|
|
|
|
|
package = pkgs.genodePackages.jitter_sponge;
|
|
|
|
|
configFile = pkgs.writeText "jitter_sponge.dhall" ''
|
|
|
|
|
let Genode = env:DHALL_GENODE
|
|
|
|
|
|
|
|
|
|
let Init = Genode.Init
|
|
|
|
|
|
|
|
|
|
in λ(binary : Text) →
|
|
|
|
|
Init.Child.flat
|
|
|
|
|
Init.Child.Attributes::{
|
|
|
|
|
, binary
|
|
|
|
|
, config = Init.Config::{
|
|
|
|
|
, policies =
|
|
|
|
|
[ Init.Config.Policy::{
|
|
|
|
|
, service = "Terminal"
|
|
|
|
|
, label = Init.LabelSelector.suffix "entropy"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
# genode.boot.storePaths = builtins.attrValues romDirectories;
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
genode.boot.configFile = bootConfigFile;
|
|
|
|
|
system.build.configFile = bootConfigFile;
|
|
|
|
|
|
|
|
|
|
# Create the tarball of the store to live in core ROM
|
|
|
|
|
system.build.tarball =
|
|
|
|
@ -421,15 +301,16 @@ in {
|
|
|
|
|
bootDriveImage = import ./lib/make-bootable-image.nix {
|
|
|
|
|
inherit config pkgs espImage storeFsImage;
|
|
|
|
|
};
|
|
|
|
|
in lib.mkIf (config.genode.boot.storeBackend != "memory") bootDriveImage;
|
|
|
|
|
in lib.mkIf (config.genode.boot.storeBackend == "fs") bootDriveImage;
|
|
|
|
|
|
|
|
|
|
virtualisation.useBootLoader = config.genode.boot.storeBackend != "memory";
|
|
|
|
|
virtualisation.useBootLoader = config.genode.boot.storeBackend == "fs";
|
|
|
|
|
|
|
|
|
|
virtualisation.qemu.options = let
|
|
|
|
|
blockCommon =
|
|
|
|
|
[ "-bios ${pkgs.buildPackages.buildPackages.OVMF.fd}/FV/OVMF.fd" ];
|
|
|
|
|
in {
|
|
|
|
|
fs = blockCommon;
|
|
|
|
|
net = [ ];
|
|
|
|
|
memory = [ ];
|
|
|
|
|
}.${config.genode.boot.storeBackend};
|
|
|
|
|
|
|
|
|
|