Genode Packages collection https://git.sr.ht/~ehmry/genodepkgs/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

genode-init.nix 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. { config, pkgs, lib, ... }:
  2. with lib;
  3. let
  4. inputs = mkOption {
  5. description = "List of packages to build a ROM store with.";
  6. type = types.listOf types.package;
  7. };
  8. in {
  9. options.genode.init = {
  10. inherit inputs;
  11. configFile = mkOption {
  12. description = ''
  13. Dhall configuration of this init instance after children have been merged.
  14. '';
  15. type = types.path;
  16. };
  17. baseConfig = mkOption {
  18. description =
  19. "Dhall configuration of this init instance before merging children.";
  20. type = types.str;
  21. default = ''
  22. let Genode = env:DHALL_GENODE
  23. in Genode.Init::{
  24. , routes =
  25. [ Genode.Init.ServiceRoute.parent "File_system"
  26. , Genode.Init.ServiceRoute.parent "Rtc"
  27. , Genode.Init.ServiceRoute.parent "Timer"
  28. , Genode.Init.ServiceRoute.parent "IRQ"
  29. , Genode.Init.ServiceRoute.parent "IO_MEM"
  30. , Genode.Init.ServiceRoute.parent "IO_PORT"
  31. ]
  32. }
  33. '';
  34. };
  35. children = mkOption {
  36. default = { };
  37. type = with types;
  38. attrsOf (submodule {
  39. options = {
  40. inherit inputs;
  41. configFile = mkOption {
  42. type = types.path;
  43. description = ''
  44. Dhall configuration of child.
  45. See https://git.sr.ht/~ehmry/dhall-genode/tree/master/Init/Child/Type
  46. '';
  47. };
  48. };
  49. });
  50. };
  51. subinits = mkOption {
  52. default = { };
  53. type = with types;
  54. attrsOf (submodule {
  55. options = {
  56. inherit inputs;
  57. configFile = mkOption {
  58. type = types.path;
  59. description = ''
  60. Dhall configuration of child init.
  61. See https://git.sr.ht/~ehmry/dhall-genode/tree/master/Init/Type
  62. '';
  63. };
  64. };
  65. });
  66. };
  67. };
  68. config = {
  69. genode.init.inputs = with builtins;
  70. [ pkgs.genodePackages.report_rom ] ++ concatLists (catAttrs "inputs"
  71. ((attrValues config.genode.init.children)
  72. ++ (attrValues config.genode.init.subinits)));
  73. # TODO: convert the subinits to children
  74. genode.init.configFile = pkgs.writeText "init.dhall" ''
  75. let Genode = env:DHALL_GENODE
  76. let baseConfig = ${config.genode.init.baseConfig}
  77. in baseConfig with children = baseConfig.children # toMap {${
  78. concatMapStrings (name:
  79. ", `${name}` = (${
  80. config.genode.init.children.${name}.configFile
  81. } : Genode.Init.Child.Type)")
  82. (builtins.attrNames config.genode.init.children)
  83. } ${
  84. concatMapStrings (name: ''
  85. , `${name}` =
  86. Genode.Init.toChild
  87. (${
  88. config.genode.init.subinits.${name}.configFile
  89. } : Genode.Init.Type)
  90. Genode.Init.Attributes.default
  91. '') (builtins.attrNames config.genode.init.subinits)
  92. } }
  93. '';
  94. };
  95. }