lib.generators.toDhall: match API with nixpkgs

This commit is contained in:
Ehmry - 2021-04-10 14:06:49 +02:00
parent de8b1a1b71
commit 99130d0f14
2 changed files with 9 additions and 8 deletions

View File

@ -95,23 +95,24 @@
(prev.attrsets.mapAttrsToList (path:
{ cap, closure }: {
path = "${pkg'}${
substring (stringLength pkg') (stringLength path') path'
substring (stringLength pkg') (stringLength path) path
}"; # hack to build a string with context
inherit cap closure;
}) erisInfo);
in assert length caps == 1; head caps;
generators = prev.generators // rec {
toDhall = x:
toDhall = { }:
x:
with builtins;
let concatItems = final.strings.concatStringsSep ", ";
in if isAttrs x then
"{ ${
concatItems (prev.attrsets.mapAttrsToList
(key: value: "${key} = ${toDhall value}") x)
(key: value: "${key} = ${toDhall { } value}") x)
} }"
else if isList x then
"[ ${concatItems (map toDhall x)} ]"
"[ ${concatItems (map (toDhall { }) x)} ]"
else if isString x || isPath x then
''"${x}"''
else if isInt x then

View File

@ -1,8 +1,8 @@
{ config, pkgs, lib, ... }:
with lib;
{
let toDhall = lib.generators.toDhall { };
in {
imports = [ ./ahci.nix ./framebuffer.nix ./nic.nix ./usb.nix ];
options.hardware.genode.platform.policies = lib.mkOption {
@ -25,7 +25,7 @@ with lib;
ahciConfig = with config.hardware.genode.ahci;
lib.optionalString enable ''
, ahci_driver = Some ${
lib.generators.toDhall {
toDhall {
binary = ahciEris.cap;
atapi = atapiSupport;
}
@ -36,7 +36,7 @@ with lib;
lib.optionalString enable ''
, usb_block = Some { binary = "${usbEris.usb_block_drv.cap}" }
, usb_driver = Some ${
lib.generators.toDhall {
toDhall {
binary = usbEris.usb_drv.cap;
bios_handoff = biosHandoff;
ehci = ehciSupport;