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

View File

@ -41,7 +41,7 @@ in {
'';
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 ${
with cfg.usb.host;
toDhall {
@ -60,7 +60,7 @@ in {
in Manager.toChildAttributes
Manager::{
, part_block.binary = "${partBlockEris.cap}"
, part_block.binary = ${partBlockEris.cap}
${ahciConfig}
${usbConfig}
, verbose = ${toDhall cfg.verbose}

View File

@ -77,8 +77,10 @@
[{
name = cap;
value = path;
}] ++ (lib.mapAttrsToList (value: name: { inherit name value; })
closure);
}] ++ (lib.mapAttrsToList (name: value: {
name = ''"${value}"'';
value = name;
}) closure);
extraRoms = map toRoms extraErisInputs;
in if binary != null then {
config = ''${configFile} "${binary}"'';
@ -86,7 +88,7 @@
} else
let bin = lib.getErisMainProgram package;
in {
config = ''${configFile} "${bin.cap}"'';
config = "${configFile} ${bin.cap}";
roms = toRoms bin ++ extraRoms;
}) 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
fileName ? "nixos-system-${stdenv.hostPlatform.system}"
fileName ? "nixos-system-${stdenv.hostPlatform.system}"
, # The files and directories to be placed in the tarball.
# This is a list of attribute sets {source, target} where `source'
# is the file system object (regular file or directory) to be
# grafted in the file system at path `target'.
dhallContents
# This is a Dhall list of attribute sets {source, target} where `source'
# is the file system object (regular file or directory) to be
# grafted in the file system at path `target'.
dhallContents
, # 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
# a list of attribute sets {object, symlink} where `object' if a
# store path whose closure will be copied, and `symlink' is a
# symlink to `object' that will be added to the tarball.
storeContents ? []
# 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
# store path whose closure will be copied, and `symlink' is a
# symlink to `object' that will be added to the tarball.
storeContents ? [ ]
# Extra commands to be executed before archiving files
, extraCommands ? ""
# Extra tar arguments
, extraArgs ? ""
}:
, extraArgs ? "" }:
let
symlinks = map (x: x.symlink) storeContents;
objects = map (x: x.object) storeContents;
in
stdenv.mkDerivation {
in stdenv.mkDerivation {
name = "tarball";
builder = ./make-system-tarball.sh;
nativeBuildInputs = [ dhall dhall-bash ];
nativeBuildInputs = [ dhall-bash lndir ];
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.
# sources = map (x: x.source) contents;
# targets = map (x: x.target) contents;
@ -42,7 +53,5 @@ stdenv.mkDerivation {
# !!! should use XML.
inherit symlinks objects;
closureInfo = closureInfo {
rootPaths = objects;
};
closureInfo = closureInfo { rootPaths = objects; };
}

View File

@ -1,7 +1,16 @@
source $stdenv/setup
dhall <<< "env:dhallContents"
exit 1
# TODO: do this with a hook
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)
symlinks=($symlinks)

View File

@ -28,11 +28,11 @@ in {
genode.core.romModules = [
{
name = "ld.lib.so";
name = ''"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";
}
];

View File

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