Avoid eris IFD

This commit is contained in:
Ehmry - 2022-05-25 14:19:32 -05:00
parent 22eab9f7e8
commit 1c7d71a00f
8 changed files with 78 additions and 51 deletions

View File

@ -23,7 +23,7 @@
( VFS.vfs ( VFS.vfs
[ VFS.leafAttrs [ VFS.leafAttrs
"plugin" "plugin"
(toMap { load = "${vfsRump.cap}", fs = "cd9660", ram = "12M", writeable="no" }) (toMap { load = ${vfsRump.cap}, fs = "cd9660", ram = "12M", writeable="no" })
] ]
) )
''; '';

View File

@ -2,6 +2,8 @@
with lib; with lib;
let let
toDhall = lib.generators.toDhall { };
localPackages = pkgs.buildPackages; localPackages = pkgs.buildPackages;
children' = config.lib.children.freeze children' = config.lib.children.freeze
@ -62,7 +64,7 @@ let
''; '';
}; };
manifest = bootManifest =
# Manifests are Dhall metadata to be attached to every # Manifests are Dhall metadata to be attached to every
# package to be used for dynamically buildings enviroments # package to be used for dynamically buildings enviroments
# using Dhall expressions. Probably not worth pursuing. # using Dhall expressions. Probably not worth pursuing.
@ -70,9 +72,9 @@ let
(with pkgs.genodePackages; storeBackendInputs ++ coreInputs)) (with pkgs.genodePackages; storeBackendInputs ++ coreInputs))
+ lib.optionalString (config.genode.core.romModules != { }) '' + lib.optionalString (config.genode.core.romModules != { }) ''
# [ { mapKey = "romModules", mapValue = [ ${ # [ { mapKey = "romModules", mapValue = [ ${
lib.concatStringsSep ", " (lib.lists.flatten ((map ({ name, value }: lib.concatStringsSep ", " (map
''{ mapKey = "${name}", mapValue = "${value}" }'') ({ name, value }: ''{ mapKey = ${name}, mapValue = "${value}" }'')
config.genode.core.romModules))) config.genode.core.romModules)
}] } ]''); }] } ]'');
extraRoutes = lib.concatStringsSep ", " (lib.lists.flatten (let extraRoutes = lib.concatStringsSep ", " (lib.lists.flatten (let
@ -105,12 +107,12 @@ let
let XML = Sigil.Prelude.XML let XML = Sigil.Prelude.XML
in in
${./store-wrapper.dhall} ${./store-wrapper.dhall}
{ binaries = { rtc_drv = "${rtc_drv.cap}" } { binaries.rtc_drv = ${rtc_drv.cap}
, extraCoreChildren = ${extraCoreChildren} , extraCoreChildren = ${extraCoreChildren}
, subinit = ${config.genode.init.configFile} , subinit = ${config.genode.init.configFile}
, storeSize = $(stat --format '%s' ${tarball}) , storeSize = $(stat --format '%s' ${tarball})
, routes = [${extraRoutes} ] : List Sigil.Init.ServiceRoute.Type , routes = [${extraRoutes} ] : List Sigil.Init.ServiceRoute.Type
, bootManifest = ${manifest} , bootManifest = ${bootManifest}
} }
EOF EOF
''; '';
@ -236,11 +238,11 @@ in {
value = path; value = path;
}) (attrValues coreErisCaps)))) ++ [ }) (attrValues coreErisCaps)))) ++ [
{ {
name = "init"; name = ''"init"'';
value = "${pkgs.genodePackages.init}/bin/init"; value = "${pkgs.genodePackages.init}/bin/init";
} }
{ {
name = "report_rom"; name = ''"report_rom"'';
value = "${pkgs.genodePackages.report_rom}/bin/report_rom"; value = "${pkgs.genodePackages.report_rom}/bin/report_rom";
} }
]; ];
@ -271,18 +273,17 @@ in {
system.build.configFile = bootConfigFile; system.build.configFile = bootConfigFile;
# Create the tarball of the store to live in core ROM # Create the tarball of the store to live in core ROM
system.build.tarball = pkgs.buildPackages.callPackage system.build.tarball = localPackages.callPackage ./make-system-tarball.nix {
"${modulesPath}/../lib/make-system-tarball.nix" { dhallContents = "[${
extraInputs = lib.attrsets.mapAttrsToList (_: child: child.package) lib.concatStringsSep ","
config.genode.init.children; (map ({ name, value }: ''{source = "${value}",target = ${name}}'')
contents = erisContents; config.genode.init.romModules)
compressCommand = "cat"; }]";
compressionExtension = ""; storeContents = lib.attrsets.mapAttrsToList (name: child: {
storeContents = lib.attrsets.mapAttrsToList (name: child: { object = child.configFile;
object = child.configFile; symlink = "/config/${name}";
symlink = "/config/${name}"; }) config.genode.init.children;
}) config.genode.init.children; };
};
system.build.initXml = pkgs.buildPackages.runCommand "init.xml" { system.build.initXml = pkgs.buildPackages.runCommand "init.xml" {
nativeBuildInputs = with pkgs.buildPackages; [ dhall xorg.lndir libxml2 ]; nativeBuildInputs = with pkgs.buildPackages; [ dhall xorg.lndir libxml2 ];

View File

@ -41,7 +41,7 @@ in {
''; '';
usbConfig = lib.optionalString cfg.usb.enable '' usbConfig = lib.optionalString cfg.usb.enable ''
, usb_block_drv = Some { binary = "${usbEris.usb_block_drv.cap}" } , usb_block_drv = Some { binary = ${usbEris.usb_block_drv.cap} }
, usb_host_drv = Some ${ , usb_host_drv = Some ${
with cfg.usb.host; with cfg.usb.host;
toDhall { toDhall {
@ -60,7 +60,7 @@ in {
in Manager.toChildAttributes in Manager.toChildAttributes
Manager::{ Manager::{
, part_block.binary = "${partBlockEris.cap}" , part_block.binary = ${partBlockEris.cap}
${ahciConfig} ${ahciConfig}
${usbConfig} ${usbConfig}
, verbose = ${toDhall cfg.verbose} , verbose = ${toDhall cfg.verbose}

View File

@ -77,8 +77,10 @@
[{ [{
name = cap; name = cap;
value = path; value = path;
}] ++ (lib.mapAttrsToList (value: name: { inherit name value; }) }] ++ (lib.mapAttrsToList (name: value: {
closure); name = ''"${value}"'';
value = name;
}) closure);
extraRoms = map toRoms extraErisInputs; extraRoms = map toRoms extraErisInputs;
in if binary != null then { in if binary != null then {
config = ''${configFile} "${binary}"''; config = ''${configFile} "${binary}"'';
@ -86,7 +88,7 @@
} else } else
let bin = lib.getErisMainProgram package; let bin = lib.getErisMainProgram package;
in { in {
config = ''${configFile} "${bin.cap}"''; config = "${configFile} ${bin.cap}";
roms = toRoms bin ++ extraRoms; roms = toRoms bin ++ extraRoms;
}) children; }) children;
}; };

View File

@ -1,40 +1,51 @@
{ stdenv, closureInfo, dhall, dhall-bash { stdenv, closureInfo, dhall-bash, dhallPackages, lndir
, # The file name of the resulting tarball , # The file name of the resulting tarball
fileName ? "nixos-system-${stdenv.hostPlatform.system}" fileName ? "nixos-system-${stdenv.hostPlatform.system}"
, # The files and directories to be placed in the tarball. , # The files and directories to be placed in the tarball.
# This is a list of attribute sets {source, target} where `source' # This is a Dhall list of attribute sets {source, target} where `source'
# is the file system object (regular file or directory) to be # is the file system object (regular file or directory) to be
# grafted in the file system at path `target'. # grafted in the file system at path `target'.
dhallContents dhallContents
, # In addition to `contents', the closure of the store paths listed , # In addition to `contents', the closure of the store paths listed
# in `packages' are also placed in the Nix store of the tarball. This is # in `packages' are also placed in the Nix store of the tarball. This is
# a list of attribute sets {object, symlink} where `object' if a # a list of attribute sets {object, symlink} where `object' if a
# store path whose closure will be copied, and `symlink' is a # store path whose closure will be copied, and `symlink' is a
# symlink to `object' that will be added to the tarball. # symlink to `object' that will be added to the tarball.
storeContents ? [] storeContents ? [ ]
# Extra commands to be executed before archiving files # Extra commands to be executed before archiving files
, extraCommands ? "" , extraCommands ? ""
# Extra tar arguments # Extra tar arguments
, extraArgs ? "" , extraArgs ? "" }:
}:
let let
symlinks = map (x: x.symlink) storeContents; symlinks = map (x: x.symlink) storeContents;
objects = map (x: x.object) storeContents; objects = map (x: x.object) storeContents;
in
stdenv.mkDerivation { in stdenv.mkDerivation {
name = "tarball"; name = "tarball";
builder = ./make-system-tarball.sh; builder = ./make-system-tarball.sh;
nativeBuildInputs = [ dhall dhall-bash ]; nativeBuildInputs = [ dhall-bash lndir ];
inherit fileName extraArgs dhallContents; inherit fileName extraArgs dhallContents;
dhallPrelude = dhallPackages.Prelude;
# TODO: this should be done with a hook
extractContents = ''
let Prelude = ${dhallPackages.Prelude}/binary.dhall
let Mapping = { source : Text, target : Text }
let Mappings = List Mapping
in \(f : Mapping -> Text) -> Prelude.List.map Mapping Text f env:dhallContents
'';
# !!! should use XML. # !!! should use XML.
# sources = map (x: x.source) contents; # sources = map (x: x.source) contents;
# targets = map (x: x.target) contents; # targets = map (x: x.target) contents;
@ -42,7 +53,5 @@ stdenv.mkDerivation {
# !!! should use XML. # !!! should use XML.
inherit symlinks objects; inherit symlinks objects;
closureInfo = closureInfo { closureInfo = closureInfo { rootPaths = objects; };
rootPaths = objects;
};
} }

View File

@ -1,7 +1,16 @@
source $stdenv/setup source $stdenv/setup
dhall <<< "env:dhallContents" # TODO: do this with a hook
exit 1 export XDG_CACHE_HOME=/tmp
lndir -silent \
$dhallPrelude/.cache \
$XDG_CACHE_HOME
eval $(dhall-to-bash --declare sources_ <<< "env:extractContents (λ(_: { source : Text, target : Text }) -> _.source)")
eval $(dhall-to-bash --declare targets_ <<< "env:extractContents (λ(_: { source : Text, target : Text }) -> _.target)")
echo $sources_
echo $targets_
objects=($objects) objects=($objects)
symlinks=($symlinks) symlinks=($symlinks)

View File

@ -28,11 +28,11 @@ in {
genode.core.romModules = [ genode.core.romModules = [
{ {
name = "ld.lib.so"; name = ''"ld.lib.so"'';
value = "${pkgs.genodePackages.base-nova}/lib/ld.lib.so"; value = "${pkgs.genodePackages.base-nova}/lib/ld.lib.so";
} }
{ {
name = "timer_drv"; name = ''"timer_drv"'';
value = "${pkgs.genodePackages.base-nova}/bin/timer_drv"; value = "${pkgs.genodePackages.base-nova}/bin/timer_drv";
} }
]; ];

View File

@ -198,7 +198,10 @@ let
runHook postInstall runHook postInstall
''; '';
meta = { platforms = lib.platforms.genode; } // meta; meta = {
mainProgram = name;
platforms = lib.platforms.genode;
} // meta;
}); });
buildDepot = buildDepot =
@ -289,7 +292,10 @@ let
''; '';
passthru = { inherit portInputs depotInputs; }; passthru = { inherit portInputs depotInputs; };
meta = { platforms = lib.platforms.genode; } // meta; meta = {
mainProgram = name;
platforms = lib.platforms.genode;
} // meta;
}); });
in self; in self;