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

View File

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