nixos-modules: convert romModules to list

This commit is contained in:
Ehmry - 2022-05-24 15:57:53 -05:00
parent 20281a8420
commit d6022ce707
3 changed files with 37 additions and 26 deletions

View File

@ -70,8 +70,8 @@ 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 ((mapAttrsToList lib.concatStringsSep ", " (lib.lists.flatten ((map ({ name, value }:
(k: v: ''{ mapKey = "${k}", mapValue = "${v}" }'') ''{ mapKey = "${name}", mapValue = "${value}" }'')
config.genode.core.romModules))) config.genode.core.romModules)))
}] } ]''); }] } ]'');
@ -115,9 +115,9 @@ let
EOF EOF
''; '';
erisContents = lib.attrsets.mapAttrsToList (urn: source: { erisContents = map ({ name, value }: {
target = urn; target = name;
inherit source; source = value;
}) config.genode.init.romModules; }) config.genode.init.romModules;
in { in {
@ -177,8 +177,8 @@ in {
}; };
romModules = mkOption { romModules = mkOption {
type = types.attrsOf types.path; type = with lib.types; listOf (attrsOf str);
default = { }; default = [ ];
description = "Attr set of initial ROM modules"; description = "Attr set of initial ROM modules";
}; };
@ -230,15 +230,20 @@ in {
}]; }];
genode.core.romModules = with builtins; genode.core.romModules = with builtins;
listToAttrs (lib.lists.flatten (lib.lists.flatten ((map (getAttr "roms") (attrValues children')) ++ (map
((map (getAttr "roms") (attrValues children')) ++ (map ({ cap, path, ... }: {
({ cap, path, ... }: { name = cap;
name = cap; value = path;
value = path; }) (attrValues coreErisCaps)))) ++ [
}) (attrValues coreErisCaps)))) // { {
"init" = "${pkgs.genodePackages.init}/bin/init"; name = "init";
"report_rom" = "${pkgs.genodePackages.report_rom}/bin/report_rom"; value = "${pkgs.genodePackages.init}/bin/init";
}; }
{
name = "report_rom";
value = "${pkgs.genodePackages.report_rom}/bin/report_rom";
}
];
genode.core.children.jitter_sponge = { genode.core.children.jitter_sponge = {
package = pkgs.genodePackages.jitter_sponge; package = pkgs.genodePackages.jitter_sponge;
@ -266,8 +271,8 @@ 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 = system.build.tarball = pkgs.buildPackages.callPackage
pkgs.buildPackages.callPackage "${modulesPath}/../lib/make-system-tarball.nix" { "${modulesPath}/../lib/make-system-tarball.nix" {
extraInputs = lib.attrsets.mapAttrsToList (_: child: child.package) extraInputs = lib.attrsets.mapAttrsToList (_: child: child.package)
config.genode.init.children; config.genode.init.children;
contents = erisContents; contents = erisContents;

View File

@ -77,8 +77,8 @@ in {
}; };
romModules = mkOption { romModules = mkOption {
type = types.attrsOf types.path; type = with lib.types; listOf (attrsOf str);
default = { }; default = [ ];
description = "Attr set of initial ROM modules"; description = "Attr set of initial ROM modules";
}; };
@ -121,8 +121,8 @@ in {
''; '';
romModules = with builtins; romModules = with builtins;
listToAttrs (lib.lists.flatten lib.lists.flatten
(map ({ roms, ... }: roms) (lib.lists.flatten (attrValues children')))); (map ({ roms, ... }: roms) (lib.lists.flatten (attrValues children')));
}; };

View File

@ -26,10 +26,16 @@ in {
genode.core.image = genode.core.image =
utils.novaImage config.system.name { } config.system.build.configFile; utils.novaImage config.system.name { } config.system.build.configFile;
genode.core.romModules = { genode.core.romModules = [
"ld.lib.so" = "${pkgs.genodePackages.base-nova}/lib/ld.lib.so"; {
timer_drv = "${pkgs.genodePackages.base-nova}/bin/timer_drv"; name = "ld.lib.so";
}; value = "${pkgs.genodePackages.base-nova}/lib/ld.lib.so";
}
{
name = "timer_drv";
value = "${pkgs.genodePackages.base-nova}/bin/timer_drv";
}
];
genode.core.storePaths = genode.core.storePaths =
lib.optional (config.genode.core.storeBackend != "memory") bootDir; lib.optional (config.genode.core.storeBackend != "memory") bootDir;