New getEris functions

This commit is contained in:
Ehmry - 2022-05-24 23:10:38 -05:00
parent d6e8db17f9
commit ea0cb3a364
8 changed files with 42 additions and 58 deletions

View File

@ -62,49 +62,32 @@
nixpkgs.lib.extend (final: prev: {
inherit forAllSystems forAllLocalSystems forAllCrossSystems;
getEris =
# For a the name of a derivation output and a derivation,
# generate a set of { cap, closure, and path } for a singular
# file found within the subdirectory of the output with the
# same name as that output. In the case that the derivation
# does not have this named output, the subdirectory will be
# taken from the default output. This subdirectory must
# contain a single file, and the output must contain an
# ERIS manifest file.
output: pkg:
getMainProgram = pkg:
with builtins;
let
pkg' = prev.getOutput output pkg;
erisInfo = fromJSON (builtins.unsafeDiscardStringContext
(readFile "${pkg'}/nix-support/eris-manifest.json"));
caps = filter
({ path, ... }: prev.strings.hasPrefix "${pkg'}/${output}" path)
(prev.attrsets.mapAttrsToList (path:
{ cap, closure }: {
path = "${pkg'}${
substring (stringLength pkg') (stringLength path) path
}"; # hack to build a string with context
inherit cap closure;
}) erisInfo);
in assert length caps == 1; head caps;
if hasAttr "mainProgram" pkg.meta then
pkg.meta.mainProgram
else
trace "${pkg.name} is missing meta.mainProgram" pkg.pname;
getEris' = output: pkg: file:
# A variant of the getEris function with file selection.
getEris = filename: pkg:
with builtins;
let
pkg' = prev.getOutput output pkg;
path' = "${pkg'}/${output}/${file}";
erisInfo = fromJSON (builtins.unsafeDiscardStringContext
(readFile "${pkg'}/nix-support/eris-manifest.json"));
caps = filter ({ path, ... }: path == path')
(prev.attrsets.mapAttrsToList (path:
{ cap, closure }: {
path = "${pkg'}${
substring (stringLength pkg') (stringLength path) path
}"; # hack to build a string with context
inherit cap closure;
}) erisInfo);
in assert length caps == 1; head caps;
manifest = fromJSON (unsafeDiscardStringContext
(readFile "${pkg}/nix-support/eris-manifest.json"));
entry = manifest.${filename};
in entry // {
cap = "(${pkg}/nix-support/eris-manifest.dhall).${filename}.cap";
path = "${pkg}${
substring (stringLength pkg) (stringLength entry.path)
entry.path
}"; # hack to build a string with context
};
getErisMainProgram = pkg:
final.getEris (final.getMainProgram pkg) (prev.getOutput "bin" pkg);
getErisLib = filename: pkg:
final.getEris filename (prev.getOutput "lib" pkg);
uuidFrom = seed:
let digest = builtins.hashString "sha256" seed;

View File

@ -8,7 +8,7 @@
genode.core.children.eris_vfs = {
fs = let
vfsRump = lib.getEris' "lib" pkgs.genodePackages.rump "vfs_rump.lib.so";
vfsRump = lib.getErisLib "vfs_rump.lib.so" pkgs.genodePackages.rump;
in {
package = pkgs.genodePackages.vfs;
extraErisInputs = [ vfsRump ];

View File

@ -13,7 +13,7 @@ let
let pkg = pkgs.genodePackages.${name};
in {
inherit name;
value = lib.getEris "bin" pkg;
value = lib.getErisMainProgram pkg;
}) pkgNames);
tarball =

View File

@ -73,9 +73,9 @@ in {
genode.core.children.gui = lib.mkIf cfg.enable (let
eris = with pkgs.genodePackages;
lib.attrsets.mapAttrs (_: lib.getEris "bin") {
lib.attrsets.mapAttrs (_: lib.getErisMainProgram) {
inherit decorator window_layouter wm;
} // (let nitpick = lib.getEris' "bin" nitpicker;
} // (let nitpick = lib.getErisMainProgram nitpicker;
in {
nitpicker = nitpick "nitpicker";
pointer = nitpick "pointer";
@ -97,11 +97,11 @@ in {
};
genode.core.children.consoleLog = lib.mkIf cfg.consoleLog.enable (let
erisInputs = (lib.attrsets.mapAttrs (_: lib.getEris "bin") {
erisInputs = (lib.attrsets.mapAttrs (_: lib.getErisMainProgram) {
inherit (pkgs.genodePackages) log_core terminal terminal_log;
}) // (lib.attrsets.mapAttrs (_: lib.getEris "lib") {
inherit (pkgs.genodePackages) vfs_ttf;
});
}) // {
vfs_ttf = lib.getErisLib "vfs_ttf.lib.so" pkgs.genodePackages.vfs_ttf;
};
in {
package = pkgs.genodePackages.init;
coreROMs = [ "core_log" "kernel_log" ];

View File

@ -22,10 +22,10 @@ in {
config = let
deviceManagerEnable = cfg.ahci.enable || cfg.usb.enable;
ahciEris = lib.getEris "bin" pkgs.genodePackages.ahci_drv;
partBlockEris = lib.getEris "bin" pkgs.genodePackages.part_block;
ahciEris = lib.getErisMainProgram pkgs.genodePackages.ahci_drv;
partBlockEris = lib.getErisMainProgram pkgs.genodePackages.part_block;
usbEris = lib.attrsets.mapAttrs (_: lib.getEris "bin") {
usbEris = lib.attrsets.mapAttrs (_: lib.getErisMainProgram) {
usb_block_drv = cfg.usb.storage.package;
usb_host_drv = cfg.usb.host.package;
};

View File

@ -84,7 +84,7 @@
config = ''${configFile} "${binary}"'';
roms = extraRoms;
} else
let bin = lib.getEris "bin" package;
let bin = lib.getErisMainProgram package;
in {
config = ''${configFile} "${bin.cap}"'';
roms = toRoms bin ++ extraRoms;

View File

@ -7,9 +7,9 @@ in {
genode.init.children.tor = let
args = lib.strings.splitString " "
config.systemd.services.tor.serviceConfig.ExecStart;
tor' = lib.getEris' "bin" pkgs.tor "tor";
lwip' = lib.getEris "lib" pkgs.genodePackages.vfs_lwip;
pipe' = lib.getEris "lib" pkgs.genodePackages.vfs_pipe;
tor' = lib.getErisMainProgram pkgs.tor;
lwip' = lib.getErisLib "vfs_lwip.lib.so" pkgs.genodePackages.vfs_lwip;
pipe' = lib.getErisLib "vfs_pipe.lib.so" pkgs.genodePackages.vfs_pipe;
in {
binary = builtins.head args;
package = pkgs.tor;

View File

@ -5,10 +5,11 @@
in {
genode.init.children.bash = let
extraErisInputs' = with pkgs.genodePackages; {
bash = lib.getEris "bin" pkgs.bash;
cached_fs_rom = lib.getEris "bin" cached_fs_rom;
vfs = lib.getEris "bin" vfs;
vfs_pipe = lib.getEris "lib" vfs_pipe;
bash =
lib.getErisMainProgram "bash" (pkgs.bash // { pname = "bash"; });
cached_fs_rom = lib.getErisMainProgram cached_fs_rom;
vfs = lib.getErisMainProgram vfs;
vfs_pipe = lib.getErisLib "vfs_pipe.lib.so" vfs_pipe;
};
params = {
bash = "${pkgs.bash}";