From e203c4b57b27c965354e7e9b06289b6d45cef28b Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Wed, 10 Jun 2020 15:22:00 +0530 Subject: [PATCH] nixos-module: graphical and fs log --- nixos-modules/default.nix | 10 +- nixos-modules/dhall/console.dhall | 1 + nixos-modules/dhall/fs-log.dhall | 58 ++++++++++++ nixos-modules/dhall/graphical-log.dhall | 107 ++++++++++++++++++++++ nixos-modules/dhall/root.dhall | 116 ++++++++---------------- nixos-modules/dhall/vbox-guest.dhall | 18 +++- 6 files changed, 225 insertions(+), 85 deletions(-) create mode 100644 nixos-modules/dhall/fs-log.dhall create mode 100644 nixos-modules/dhall/graphical-log.dhall diff --git a/nixos-modules/default.nix b/nixos-modules/default.nix index b752861..871bafb 100644 --- a/nixos-modules/default.nix +++ b/nixos-modules/default.nix @@ -88,8 +88,11 @@ ./dhall/root.dhall } { fbDriver = ${fbDriverConfig}, guests = toMap { console = ${console} } # ${guestChildren}, inputFilterChargens = ${genodeConfig.inputFilter.extraChargen}, partitionType = ${ ./dhall/partition-type - }, wm = ${./dhall/wm.dhall} - }''; + }, wm = ${./dhall/wm.dhall}, graphical-log = ${ + ./dhall/graphical-log.dhall + }, fs-log = ${ + ./dhall/fs-log.dhall + }, systemLabel = "${config.system.nixos.label}" }''; buildBootDescription = self.legacyPackages.x86_64-linux.callPackage ./buildBootDescription.nix { lib = lib'; }; @@ -103,6 +106,7 @@ "cached_fs_rom" "chroot" "decorator" + "fs_log" "init" "input_filter" "ipxe_nic_drv" @@ -117,7 +121,7 @@ "posix" "ps2_drv" "report_rom" - "rom_logger" + "rom_to_file" "rtc_drv" "rump" "stdcxx" diff --git a/nixos-modules/dhall/console.dhall b/nixos-modules/dhall/console.dhall index a504af1..272b3c8 100644 --- a/nixos-modules/dhall/console.dhall +++ b/nixos-modules/dhall/console.dhall @@ -38,6 +38,7 @@ in λ(params : { bash : Text, coreutils : Text, path : Text }) , initial_height = "600" } } + , exitPropagate = True , provides = [ "Framebuffer", "Input" ] , resources = Resources::{ ram = Genode.units.MiB 8 } } diff --git a/nixos-modules/dhall/fs-log.dhall b/nixos-modules/dhall/fs-log.dhall new file mode 100644 index 0000000..0671ae0 --- /dev/null +++ b/nixos-modules/dhall/fs-log.dhall @@ -0,0 +1,58 @@ +-- SPDX-License-Identifier: CC0-1.0 + +let Genode = env:DHALL_GENODE + +let Init = Genode.Init + +let Child = Init.Child + +let ServiceRoute = Init.ServiceRoute + +let routeLogRom = + λ(label : Text) → ServiceRoute.parentLabel "ROM" (Some "log") (Some label) + +in Init::{ + , verbose = True + , children = toMap + { fs_log = + Child.flat + Child.Attributes::{ + , binary = "fs_log" + , config = Init.Config::{ + , defaultPolicy = Some Init.Config.DefaultPolicy::{ + , attributes = toMap { merge = "yes", truncate = "yes" } + } + } + , exitPropagate = True + , provides = [ "LOG" ] + , routes = [ ServiceRoute.parent "File_system" ] + } + , log_core = + Child.flat + Child.Attributes::{ + , binary = "log_core" + , routes = + [ routeLogRom "core_log" + , ServiceRoute.childLabel + "LOG" + "fs_log" + (Some "log") + (Some "core") + ] + } + , log_kernel = + Child.flat + Child.Attributes::{ + , binary = "log_core" + , routes = + [ routeLogRom "kernel_log" + , ServiceRoute.childLabel + "LOG" + "fs_log" + (Some "log") + (Some "kernel") + ] + } + } + , routes = [ ServiceRoute.parent "Timer" ] + } diff --git a/nixos-modules/dhall/graphical-log.dhall b/nixos-modules/dhall/graphical-log.dhall new file mode 100644 index 0000000..30fee83 --- /dev/null +++ b/nixos-modules/dhall/graphical-log.dhall @@ -0,0 +1,107 @@ +-- SPDX-License-Identifier: CC0-1.0 + +let Genode = env:DHALL_GENODE + +let Prelude = Genode.Prelude + +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 Init::{ + , verbose = True + , routes = + Prelude.List.map + Text + Init.ServiceRoute.Type + Init.ServiceRoute.parent + [ "Nitpicker", "Rtc", "Timer" ] + , children = toMap + { nit_fb = + Child.flat + Child.Attributes::{ + , binary = "nit_fb" + , config = Init.Config::{ + , attributes = toMap + { initial_width = "600", initial_height = "600" } + } + , exitPropagate = True + , provides = [ "Framebuffer", "Input" ] + , resources = Resources::{ ram = Genode.units.MiB 8 } + } + , terminal = + Child.flat + Child.Attributes::{ + , binary = "terminal" + , config = Init.Config::{ + , content = + [ XML.element + { name = "vfs" + , attributes = XML.emptyAttributes + , content = + [ XML.element + { name = "dir" + , attributes = toMap { name = "fonts" } + , content = + [ XML.leaf + { name = "fs" + , attributes = toMap { label = "fonts" } + } + ] + } + ] + } + ] + } + , provides = [ "Terminal" ] + , resources = Resources::{ caps = 256, ram = Genode.units.MiB 4 } + , routes = + [ ServiceRoute.child "Framebuffer" "nit_fb" + , ServiceRoute.child "Input" "nit_fb" + , ServiceRoute.parent "File_system" + ] + } + , terminal_log = + Child.flat + Child.Attributes::{ + , binary = "terminal_log" + , provides = [ "LOG" ] + , routes = [ ServiceRoute.child "Terminal" "terminal" ] + } + , log_core = + Child.flat + Child.Attributes::{ + , binary = "log_core" + , routes = + [ routeLogRom "core_log" + , ServiceRoute.childLabel + "LOG" + "terminal_log" + (Some "log") + (Some "core") + ] + } + , log_kernel = + Child.flat + Child.Attributes::{ + , binary = "log_core" + , routes = + [ routeLogRom "kernel_log" + , ServiceRoute.childLabel + "LOG" + "terminal_log" + (Some "log") + (Some "kernel") + ] + } + } + } diff --git a/nixos-modules/dhall/root.dhall b/nixos-modules/dhall/root.dhall index 81d9f07..eb7fe6f 100644 --- a/nixos-modules/dhall/root.dhall +++ b/nixos-modules/dhall/root.dhall @@ -24,9 +24,6 @@ let label = λ(label : Text) → { local = label, route = label } : Child.Attributes.Label -let routeLogRom = - λ(label : Text) → ServiceRoute.parentLabel "ROM" (Some "log") (Some label) - let rootInit = λ ( params : { fbDriver : Init.Child.Type @@ -34,6 +31,9 @@ let rootInit = , inputFilterChargens : List XML.Type , partitionType : Text , wm : Init.Type + , graphical-log : Init.Type + , fs-log : Init.Type + , systemLabel : Text } ) → Init::{ @@ -404,89 +404,44 @@ let rootInit = } , routes = [ ServiceRoute.child "Block" "block_router" ] } - , nit_fb = - Child.flat - Child.Attributes::{ - , binary = "nit_fb" - , config = Init.Config::{ - , attributes = toMap { initial_width = "600" } - } - , provides = [ "Framebuffer", "Input" ] - , resources = Resources::{ ram = Genode.units.MiB 8 } + , graphical-log = + Init.toChild + params.graphical-log + Init.Attributes::{ , routes = - [ ServiceRoute.childLabel - "Nitpicker" - "wm" - (None Text) - (Some "log") - ] - } - , terminal = - Child.flat - Child.Attributes::{ - , binary = "terminal" - , config = Init.Config::{ - , content = - [ XML.element - { name = "vfs" - , attributes = XML.emptyAttributes - , content = - [ XML.element - { name = "dir" - , attributes = toMap { name = "fonts" } - , content = - [ XML.leaf - { name = "fs" - , attributes = toMap { label = "fonts" } - } - ] - } - ] - } - ] - } - , provides = [ "Terminal" ] - , resources = Resources::{ - , caps = 256 - , ram = Genode.units.MiB 4 - } - , routes = - [ ServiceRoute.child "Framebuffer" "nit_fb" - , ServiceRoute.child "Input" "nit_fb" + [ ServiceRoute.child "Nitpicker" "wm" , ServiceRoute.child "File_system" "fonts_fs" ] } - , terminal_log = - Child.flat - Child.Attributes::{ - , binary = "terminal_log" - , provides = [ "LOG" ] - , routes = [ ServiceRoute.child "Terminal" "terminal" ] - } - , log_core = - Child.flat - Child.Attributes::{ - , binary = "log_core" + , fs-log = + Init.toChild + params.fs-log + Init.Attributes::{ , routes = - [ routeLogRom "core_log" - , ServiceRoute.childLabel - "LOG" - "terminal_log" - (Some "log") - (Some "core") + [ ServiceRoute.childLabel + "File_system" + "chroot" + (None Text) + (Some "dump") ] } - , log_kernel = + , rom_to_file = Child.flat Child.Attributes::{ - , binary = "log_core" + , binary = "rom_to_file" + , config = Init.Config::{ + , attributes = toMap { rom = "init.config" } + } , routes = - [ routeLogRom "kernel_log" - , ServiceRoute.childLabel - "LOG" - "terminal_log" - (Some "log") - (Some "kernel") + [ ServiceRoute.childLabel + "File_system" + "chroot" + (None Text) + (Some "dump") + , ServiceRoute.parentLabel + "ROM" + (Some "init.config") + (Some "config") ] } , block = @@ -616,7 +571,7 @@ let rootInit = , Policy::{ , label = LabelSelector.prefix "chroot" , attributes = toMap - { root = "/ext2", writeable = "yes" } + { root = "/ext2", writeable = "yes", path = "/" } } , Policy::{ , label = LabelSelector.prefix "init -> console" @@ -636,6 +591,13 @@ let rootInit = Child.Attributes::{ , binary = "chroot" , config = Init.Config::{ + , policies = + [ Policy::{ + , label = LabelSelector.label "dump" + , attributes = toMap + { path = params.systemLabel, writeable = "yes" } + } + ] , defaultPolicy = Some DefaultPolicy::{ , attributes = toMap { writeable = "yes" } } diff --git a/nixos-modules/dhall/vbox-guest.dhall b/nixos-modules/dhall/vbox-guest.dhall index 3185369..76bf871 100644 --- a/nixos-modules/dhall/vbox-guest.dhall +++ b/nixos-modules/dhall/vbox-guest.dhall @@ -171,10 +171,6 @@ let toVbox = let mutableVfs = let fsNode = [ XML.leaf - { name = "ram" - , attributes = XML.emptyAttributes - } - , XML.leaf { name = "fs" , attributes = toMap { label = "nix/store" @@ -184,7 +180,19 @@ let toVbox = ] in merge - { ISO = fsNode + { ISO = + [ XML.leaf + { name = "fs" + , attributes = toMap + { writeable = "yes" } + } + , XML.element + { name = "import" + , attributes = toMap + { overwrite = "no" } + , content = fsNode + } + ] , VDI = [ XML.leaf { name = "fs"