diff --git a/nixos-modules/hardware.nix b/nixos-modules/hardware.nix index 4066ac4..c2d7b24 100644 --- a/nixos-modules/hardware.nix +++ b/nixos-modules/hardware.nix @@ -30,6 +30,8 @@ with lib; ''; }; + hardware.usb.genode.enable = lib.mkEnableOption "USB driver"; + }; config = { @@ -199,7 +201,7 @@ with lib; }; }) config.networking.interfaces; - in nics // (lib.filterAttrs (n: v: v != null) sockets) // { + in lib.filterAttrs (n: v: v != null) (nics // sockets // { acpi_drv = { coreROMs = [ "acpi_drv" ]; @@ -260,7 +262,32 @@ with lib; ''; }; - }; + usb_drv = if config.hardware.usb.genode.enable then { + inputs = [ pkgs.genodePackages.usb_drv ]; + configFile = pkgs.writeText "${name'}.dhall" '' + let Genode = env:DHALL_GENODE + + let XML = Genode.Prelude.XML + + let Init = Genode.Init + + in Init.Child.flat + Init.Child.Attributes::{ + , binary = "usb_drv" + , provides = [ "Usb" ] + , resources = Init.Resources::{ caps = 256, ram = Genode.units.MiB 12 } + , routes = [ Init.ServiceRoute.parent "IO_MEM" ] + , config = Init.Config::{ + , attributes = toMap { uhci = "yes", ehci = "yes", xhci = "yes" } + , content = + [ XML.leaf { name = "raw", attributes = XML.emptyAttributes } ] + } + } + ''; + } else + null; + + }); };