nixos: add graphical log
This commit is contained in:
parent
5b892d6a50
commit
bc2ae726f3
162
nixos-modules/gui/consoleLog.dhall
Normal file
162
nixos-modules/gui/consoleLog.dhall
Normal file
|
@ -0,0 +1,162 @@
|
||||||
|
let Genode = env:DHALL_GENODE
|
||||||
|
|
||||||
|
let Prelude = Genode.Prelude
|
||||||
|
|
||||||
|
let VFS = Genode.VFS
|
||||||
|
|
||||||
|
let XML = Prelude.XML
|
||||||
|
|
||||||
|
let Init = Genode.Init
|
||||||
|
|
||||||
|
let Child = Init.Child
|
||||||
|
|
||||||
|
let Resources = Init.Resources
|
||||||
|
|
||||||
|
let ServiceRoute = Init.ServiceRoute
|
||||||
|
|
||||||
|
let routeLogRom =
|
||||||
|
λ(label : Text) → ServiceRoute.parentLabel "ROM" (Some "log") (Some label)
|
||||||
|
|
||||||
|
in λ(params : { fontFile : Text }) →
|
||||||
|
Init.toChild
|
||||||
|
Init::{
|
||||||
|
, verbose = True
|
||||||
|
, routes =
|
||||||
|
[ Init.ServiceRoute.parent "Gui", Init.ServiceRoute.parent "Timer" ]
|
||||||
|
, children = toMap
|
||||||
|
{ gui_fb =
|
||||||
|
Child.flat
|
||||||
|
Child.Attributes::{
|
||||||
|
, binary = "gui_fb"
|
||||||
|
, exitPropagate = True
|
||||||
|
, resources = Resources::{ ram = Genode.units.MiB 8 }
|
||||||
|
, config = Init.Config::{
|
||||||
|
, attributes = toMap
|
||||||
|
{ origin = "top_right"
|
||||||
|
, xpos = "0"
|
||||||
|
, ypos = "0"
|
||||||
|
, initial_width = "1024"
|
||||||
|
, initial_height = "768"
|
||||||
|
}
|
||||||
|
, policies =
|
||||||
|
[ Init.Config.Policy::{
|
||||||
|
, service = "Framebuffer"
|
||||||
|
, label = Init.LabelSelector.prefix "terminal"
|
||||||
|
}
|
||||||
|
, Init.Config.Policy::{
|
||||||
|
, service = "Input"
|
||||||
|
, label = Init.LabelSelector.prefix "terminal"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
, terminal =
|
||||||
|
Child.flat
|
||||||
|
Child.Attributes::{
|
||||||
|
, binary = "terminal"
|
||||||
|
, exitPropagate = True
|
||||||
|
, resources = Resources::{
|
||||||
|
, caps = 256
|
||||||
|
, ram = Genode.units.MiB 4
|
||||||
|
}
|
||||||
|
, routes =
|
||||||
|
[ ServiceRoute.child "Framebuffer" "gui_fb"
|
||||||
|
, ServiceRoute.child "Input" "gui_fb"
|
||||||
|
, ServiceRoute.parent "File_system"
|
||||||
|
]
|
||||||
|
, config = Init.Config::{
|
||||||
|
, content =
|
||||||
|
[ XML.element
|
||||||
|
{ name = "palette"
|
||||||
|
, attributes = toMap
|
||||||
|
{ uri = "https://pippin.gimp.org/ametameric/" }
|
||||||
|
, content =
|
||||||
|
let color =
|
||||||
|
λ(index : Natural) →
|
||||||
|
λ(value : Text) →
|
||||||
|
XML.leaf
|
||||||
|
{ name = "color"
|
||||||
|
, attributes = toMap
|
||||||
|
{ index = Natural/show index
|
||||||
|
, value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
in [ color 0 "#000000"
|
||||||
|
, color 1 "#a02929"
|
||||||
|
, color 2 "#4aa08b"
|
||||||
|
, color 3 "#878453"
|
||||||
|
, color 4 "#2424ed"
|
||||||
|
, color 5 "#ab4adf"
|
||||||
|
, color 6 "#3b6bb1"
|
||||||
|
, color 7 "#c3c3c3"
|
||||||
|
, color 8 "#6f6f6f"
|
||||||
|
, color 9 "#edac82"
|
||||||
|
, color 10 "#99edba"
|
||||||
|
, color 11 "#e9d808"
|
||||||
|
, color 12 "#82b4ed"
|
||||||
|
, color 13 "#d66fed"
|
||||||
|
, color 14 "#1de1ed"
|
||||||
|
, color 15 "#ffffff"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
, VFS.vfs
|
||||||
|
[ VFS.leafAttrs
|
||||||
|
"rom"
|
||||||
|
(toMap { name = params.fontFile })
|
||||||
|
, VFS.dir
|
||||||
|
"fonts"
|
||||||
|
[ VFS.dir
|
||||||
|
"monospace"
|
||||||
|
[ VFS.leafAttrs
|
||||||
|
"ttf"
|
||||||
|
( toMap
|
||||||
|
{ name = "regular"
|
||||||
|
, path = params.fontFile
|
||||||
|
, size_px = "10"
|
||||||
|
}
|
||||||
|
)
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
, policies =
|
||||||
|
[ Init.Config.Policy::{
|
||||||
|
, service = "Terminal"
|
||||||
|
, label = Init.LabelSelector.prefix "terminal_log"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
, terminal_log =
|
||||||
|
Child.flat
|
||||||
|
Child.Attributes::{
|
||||||
|
, binary = "terminal_log"
|
||||||
|
, config = Init.Config::{
|
||||||
|
, policies =
|
||||||
|
[ Init.Config.Policy::{
|
||||||
|
, service = "LOG"
|
||||||
|
, label = Init.LabelSelector.prefix "core"
|
||||||
|
}
|
||||||
|
, Init.Config.Policy::{
|
||||||
|
, service = "LOG"
|
||||||
|
, label = Init.LabelSelector.prefix "kernel"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
, core =
|
||||||
|
Child.flat
|
||||||
|
Child.Attributes::{
|
||||||
|
, binary = "log_core"
|
||||||
|
, routes = [ routeLogRom "core_log" ]
|
||||||
|
}
|
||||||
|
, kernel =
|
||||||
|
Child.flat
|
||||||
|
Child.Attributes::{
|
||||||
|
, binary = "log_core"
|
||||||
|
, routes = [ routeLogRom "kernel_log" ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Init.Attributes.default
|
56
nixos-modules/gui/default.nix
Normal file
56
nixos-modules/gui/default.nix
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
{ config, pkgs, lib, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
let cfg = config.genode.gui;
|
||||||
|
in {
|
||||||
|
options.genode.gui = {
|
||||||
|
enable = mkEnableOption "Genode Gui service";
|
||||||
|
consoleLog = { enable = mkEnableOption "console log"; };
|
||||||
|
};
|
||||||
|
|
||||||
|
config = {
|
||||||
|
|
||||||
|
genode.gui.enable = cfg.consoleLog.enable;
|
||||||
|
|
||||||
|
hardware.genode.framebuffer.enable = cfg.enable;
|
||||||
|
|
||||||
|
genode.core.children.nitpicker = mkIf cfg.enable {
|
||||||
|
inputs = [ pkgs.genodePackages.nitpicker ];
|
||||||
|
configFile = pkgs.writeText "nitpicker.dhall" ''
|
||||||
|
let Init = (env:DHALL_GENODE).Init
|
||||||
|
|
||||||
|
in ${./nitpicker.dhall}
|
||||||
|
{ policies =
|
||||||
|
[ Init.Config.Policy::{
|
||||||
|
, service = "Gui"
|
||||||
|
, label = Init.LabelSelector.prefix "consoleLog"
|
||||||
|
, attributes = toMap { domain = "default" }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
genode.boot.romModules = mkIf cfg.consoleLog.enable {
|
||||||
|
"TerminusTTF.ttf" = pkgs.buildPackages.terminus_font_ttf
|
||||||
|
+ "/share/fonts/truetype/TerminusTTF.ttf";
|
||||||
|
};
|
||||||
|
|
||||||
|
genode.core.children.consoleLog = mkIf cfg.consoleLog.enable {
|
||||||
|
inputs = with pkgs.genodePackages; [
|
||||||
|
gui_fb
|
||||||
|
log_core
|
||||||
|
libc
|
||||||
|
terminal
|
||||||
|
terminal_log
|
||||||
|
vfs_ttf
|
||||||
|
];
|
||||||
|
coreROMs = [ "core_log" "kernel_log" ];
|
||||||
|
configFile = pkgs.writeText "consoleLog.dhall" ''
|
||||||
|
${./consoleLog.dhall} { fontFile = "TerminusTTF.ttf" }
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
42
nixos-modules/gui/nitpicker.dhall
Normal file
42
nixos-modules/gui/nitpicker.dhall
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
let Genode = env:DHALL_GENODE
|
||||||
|
|
||||||
|
let XML = Genode.Prelude.XML
|
||||||
|
|
||||||
|
let Init = Genode.Init
|
||||||
|
|
||||||
|
in λ(params : { policies : List Init.Config.Policy.Type }) →
|
||||||
|
Init.Child.flat
|
||||||
|
Init.Child.Attributes::{
|
||||||
|
, binary = "nitpicker"
|
||||||
|
, resources = Init.Resources::{ ram = Genode.units.MiB 4 }
|
||||||
|
, config = Init.Config::{
|
||||||
|
, attributes = toMap
|
||||||
|
{ note = "Nitpicker config is extremely fragile!" }
|
||||||
|
, content =
|
||||||
|
[ XML.leaf { name = "capture", attributes = XML.emptyAttributes }
|
||||||
|
, XML.leaf
|
||||||
|
{ name = "domain"
|
||||||
|
, attributes = toMap
|
||||||
|
{ name = "default"
|
||||||
|
, layer = "1"
|
||||||
|
, content = "client"
|
||||||
|
, label = "no"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
, XML.leaf
|
||||||
|
{ name = "background"
|
||||||
|
, attributes = toMap { color = "#000000" }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
, policies =
|
||||||
|
params.policies
|
||||||
|
# [ Init.Config.Policy::{
|
||||||
|
, service = "Capture"
|
||||||
|
, label = Init.LabelSelector.prefix "fb_drv"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
, defaultPolicy = Some Init.Config.DefaultPolicy::{
|
||||||
|
, attributes = toMap { domain = "default" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,11 +10,15 @@ with lib;
|
||||||
attrsOf (submodule ({ ... }: {
|
attrsOf (submodule ({ ... }: {
|
||||||
options.genode = {
|
options.genode = {
|
||||||
|
|
||||||
driver = mkOption { type = types.enum [ "ipxe" "virtio" ]; };
|
driver = mkOption {
|
||||||
|
type = types.enum [ "ipxe" "virtio" ];
|
||||||
|
description = "Nic driver to use for this interface.";
|
||||||
|
};
|
||||||
|
|
||||||
stack = mkOption {
|
stack = mkOption {
|
||||||
type = with types; nullOr (enum [ "lwip" "lxip" ]);
|
type = with types; nullOr (enum [ "lwip" "lxip" ]);
|
||||||
default = "lwip";
|
default = "lwip";
|
||||||
|
description = "IP stack to use for this interface.";
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -30,10 +34,20 @@ with lib;
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
hardware.usb.genode.enable = lib.mkEnableOption "USB driver";
|
hardware.genode = {
|
||||||
|
|
||||||
hardware.usb.genode.storage.enable =
|
usb.enable = lib.mkEnableOption "USB driver";
|
||||||
lib.mkEnableOption "USB mass storage driver";
|
usb.storage.enable = lib.mkEnableOption "USB mass storage driver";
|
||||||
|
|
||||||
|
framebuffer = {
|
||||||
|
enable = lib.mkEnableOption "framebuffer driver";
|
||||||
|
driver = mkOption {
|
||||||
|
type = types.enum [ "boot" "vesa" ];
|
||||||
|
default = "vesa";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -52,10 +66,10 @@ with lib;
|
||||||
in lib.mapAttrsToList addrCheck config.networking.interfaces
|
in lib.mapAttrsToList addrCheck config.networking.interfaces
|
||||||
++ lib.mapAttrsToList routeCheck config.networking.interfaces;
|
++ lib.mapAttrsToList routeCheck config.networking.interfaces;
|
||||||
|
|
||||||
hardware.usb.genode.storage.enable = config.genode.boot.storeBackend
|
hardware.genode.usb.storage.enable = config.genode.boot.storeBackend
|
||||||
== "usb";
|
== "usb";
|
||||||
|
|
||||||
hardware.usb.genode.enable = config.hardware.usb.genode.storage.enable;
|
hardware.genode.usb.enable = config.hardware.genode.usb.storage.enable;
|
||||||
|
|
||||||
hardware.genode.platform.policies = lib.lists.imap0 (i: name:
|
hardware.genode.platform.policies = lib.lists.imap0 (i: name:
|
||||||
builtins.toFile (name + ".platform-policy.dhall") ''
|
builtins.toFile (name + ".platform-policy.dhall") ''
|
||||||
|
@ -75,7 +89,19 @@ with lib;
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
'') (builtins.attrNames config.networking.interfaces)
|
'') (builtins.attrNames config.networking.interfaces)
|
||||||
++ lib.optional config.hardware.usb.genode.enable
|
++ lib.optional config.hardware.genode.framebuffer.enable
|
||||||
|
(builtins.toFile ("framebuffer.platform-policy.dhall") ''
|
||||||
|
let Genode = env:DHALL_GENODE
|
||||||
|
|
||||||
|
in Genode.Init.Config.Policy::{
|
||||||
|
, service = "Platform"
|
||||||
|
, label = Genode.Init.LabelSelector.prefix "fb_drv"
|
||||||
|
, content =
|
||||||
|
[ Genode.Prelude.XML.leaf
|
||||||
|
{ name = "pci", attributes = toMap { class = "VGA" } }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
'') ++ lib.optional config.hardware.genode.usb.enable
|
||||||
(builtins.toFile ("usb.platform-policy.dhall") ''
|
(builtins.toFile ("usb.platform-policy.dhall") ''
|
||||||
let Genode = env:DHALL_GENODE
|
let Genode = env:DHALL_GENODE
|
||||||
|
|
||||||
|
@ -89,11 +115,6 @@ with lib;
|
||||||
}
|
}
|
||||||
'');
|
'');
|
||||||
|
|
||||||
genode.core.basePackages = with pkgs.genodePackages;
|
|
||||||
[ acpi_drv platform_drv ]
|
|
||||||
++ lib.optional config.hardware.usb.genode.enable
|
|
||||||
pkgs.genodePackages.usb_drv;
|
|
||||||
|
|
||||||
genode.init.children = let
|
genode.init.children = let
|
||||||
|
|
||||||
nics = mapAttrs' (name: interface:
|
nics = mapAttrs' (name: interface:
|
||||||
|
@ -125,8 +146,7 @@ with lib;
|
||||||
|
|
||||||
in Init.Child.flat
|
in Init.Child.flat
|
||||||
Init.Child.Attributes::{
|
Init.Child.Attributes::{
|
||||||
, binary = "${binary.pname}"
|
, binary = "${binary}/bin/${binary.pname}"
|
||||||
, provides = [ "Nic" ]
|
|
||||||
, resources = Init.Resources::{
|
, resources = Init.Resources::{
|
||||||
, caps = 128
|
, caps = 128
|
||||||
, ram = Genode.units.MiB 4
|
, ram = Genode.units.MiB 4
|
||||||
|
@ -227,10 +247,8 @@ with lib;
|
||||||
|
|
||||||
in lib.filterAttrs (n: v: v != null) (nics // sockets);
|
in lib.filterAttrs (n: v: v != null) (nics // sockets);
|
||||||
|
|
||||||
genode.core.children = {
|
genode.core.children.acpi_drv = {
|
||||||
|
inputs = [ pkgs.genodePackages.acpi_drv ];
|
||||||
acpi_drv = {
|
|
||||||
coreROMs = [ "acpi_drv" ];
|
|
||||||
configFile = pkgs.writeText "acpi_drv.dhall" ''
|
configFile = pkgs.writeText "acpi_drv.dhall" ''
|
||||||
let Genode = env:DHALL_GENODE
|
let Genode = env:DHALL_GENODE
|
||||||
|
|
||||||
|
@ -256,11 +274,11 @@ with lib;
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
platform_drv = {
|
genode.core.children.platform_drv = {
|
||||||
coreROMs = [ "platform_drv" ];
|
inputs = [ pkgs.genodePackages.platform_drv ];
|
||||||
configFile = let
|
configFile = let
|
||||||
policies = map (policy: ", ${policy}")
|
policies =
|
||||||
config.hardware.genode.platform.policies;
|
map (policy: ", ${policy}") config.hardware.genode.platform.policies;
|
||||||
in pkgs.writeText "platform_drv.dhall" ''
|
in pkgs.writeText "platform_drv.dhall" ''
|
||||||
let Genode = env:DHALL_GENODE
|
let Genode = env:DHALL_GENODE
|
||||||
|
|
||||||
|
@ -275,7 +293,6 @@ with lib;
|
||||||
, constrainPhys = True
|
, constrainPhys = True
|
||||||
}
|
}
|
||||||
, reportRoms = let label = "acpi" in [ { local = label, route = label } ]
|
, reportRoms = let label = "acpi" in [ { local = label, route = label } ]
|
||||||
, provides = [ "Platform" ]
|
|
||||||
, routes =
|
, routes =
|
||||||
[ Init.ServiceRoute.parent "IRQ"
|
[ Init.ServiceRoute.parent "IRQ"
|
||||||
, Init.ServiceRoute.parent "IO_MEM"
|
, Init.ServiceRoute.parent "IO_MEM"
|
||||||
|
@ -287,10 +304,9 @@ with lib;
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
} // (if config.hardware.usb.genode.enable then {
|
|
||||||
|
|
||||||
usb_drv = {
|
genode.core.children.usb_drv = mkIf config.hardware.genode.usb.enable {
|
||||||
coreROMs = [ "usb_drv" ];
|
inputs = [ pkgs.genodePackages.usb_drv ];
|
||||||
configFile = builtins.toFile "usb_drv.dhall" ''
|
configFile = builtins.toFile "usb_drv.dhall" ''
|
||||||
let Genode = env:DHALL_GENODE
|
let Genode = env:DHALL_GENODE
|
||||||
|
|
||||||
|
@ -299,16 +315,12 @@ with lib;
|
||||||
let Init = Genode.Init
|
let Init = Genode.Init
|
||||||
|
|
||||||
let storageEnable = ${
|
let storageEnable = ${
|
||||||
if config.hardware.usb.genode.storage.enable then
|
if config.hardware.genode.usb.storage.enable then "True" else "False"
|
||||||
"True"
|
|
||||||
else
|
|
||||||
"False"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
in Init.Child.flat
|
in Init.Child.flat
|
||||||
Init.Child.Attributes::{
|
Init.Child.Attributes::{
|
||||||
, binary = "usb_drv"
|
, binary = "usb_drv"
|
||||||
, provides = [ "Block", "Usb" ]
|
|
||||||
, resources = Init.Resources::{ caps = 256, ram = Genode.units.MiB 12 }
|
, resources = Init.Resources::{ caps = 256, ram = Genode.units.MiB 12 }
|
||||||
, routes = [ Init.ServiceRoute.parent "IO_MEM" ]
|
, routes = [ Init.ServiceRoute.parent "IO_MEM" ]
|
||||||
, config = Init.Config::{
|
, config = Init.Config::{
|
||||||
|
@ -323,7 +335,7 @@ with lib;
|
||||||
if storageEnable
|
if storageEnable
|
||||||
then [ Init.Config.Policy::{
|
then [ Init.Config.Policy::{
|
||||||
, service = "Block"
|
, service = "Block"
|
||||||
, label = Init.LabelSelector.prefix "store_fs"
|
, label = Init.LabelSelector.prefix "part_block"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
else [] : List Init.Config.Policy.Type
|
else [] : List Init.Config.Policy.Type
|
||||||
|
@ -331,8 +343,38 @@ with lib;
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
} else
|
|
||||||
{ });
|
genode.core.children.fb_drv =
|
||||||
|
mkIf config.hardware.genode.framebuffer.enable {
|
||||||
|
inputs = with pkgs.genodePackages;
|
||||||
|
{
|
||||||
|
"boot" = [ boot_fb_drv ];
|
||||||
|
"vesa" = [ vesa_drv ];
|
||||||
|
}.${config.hardware.genode.framebuffer.driver};
|
||||||
|
configFile = let
|
||||||
|
binary = with pkgs.genodePackages;
|
||||||
|
{
|
||||||
|
"boot" = "boot_fb_drv";
|
||||||
|
"vesa" = "vesa_fb_drv";
|
||||||
|
}.${config.hardware.genode.framebuffer.driver};
|
||||||
|
in builtins.toFile "fb_drv.dhall" ''
|
||||||
|
let Genode = env:DHALL_GENODE
|
||||||
|
|
||||||
|
let XML = Genode.Prelude.XML
|
||||||
|
|
||||||
|
let Init = Genode.Init
|
||||||
|
|
||||||
|
in Init.Child.flat
|
||||||
|
Init.Child.Attributes::{
|
||||||
|
, binary = "${binary}"
|
||||||
|
, resources = Init.Resources::{ caps = 256, ram = Genode.units.MiB 32 }
|
||||||
|
, routes =
|
||||||
|
[ Init.ServiceRoute.parent "IO_MEM"
|
||||||
|
, Init.ServiceRoute.parent "IO_PORT"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ rec {
|
||||||
baseModules = (import "${modulesPath}/module-list.nix") ++ [
|
baseModules = (import "${modulesPath}/module-list.nix") ++ [
|
||||||
../../nixos-modules/genode-core.nix
|
../../nixos-modules/genode-core.nix
|
||||||
../../nixos-modules/genode-init.nix
|
../../nixos-modules/genode-init.nix
|
||||||
|
../../nixos-modules/gui
|
||||||
../../nixos-modules/hardware.nix
|
../../nixos-modules/hardware.nix
|
||||||
../../nixos-modules/qemu-vm.nix
|
../../nixos-modules/qemu-vm.nix
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user