let Genode = env:DHALL_GENODE

let Prelude = Genode.Prelude

let XML = Prelude.XML

let service = λ(s : Text) → { service = s, label = None Text }

let serviceLabel = λ(s : Text) → λ(l : Text) → { service = s, label = Some l }

let fsService = λ(l : Text) → serviceLabel "file_system" l

in  { indexInfo =
        "Noux administration environment"
    , runtime =
          Genode.Runtime.defaults
        ⫽ { ram =
              Genode.units.MiB 72
          , caps =
              1000
          , requires =
              [ fsService "config"
              , fsService "report"
              , fsService "target"
              , fsService "fonts"
              , service "nitpicker"
              , serviceLabel "report" "clipboard"
              , serviceLabel "rom" "clipboard"
              ]
          , roms =
              [ "libc.lib.so"
              , "libm.lib.so"
              , "init"
              , "terminal"
              , "noux"
              , "libc_noux.lib.so"
              , "posix.lib.so"
              , "ncurses.lib.so"
              , "bash-minimal.tar"
              , "coreutils-minimal.tar"
              , "vim-minimal.tar"
              , "vfs.lib.so"
              ]
          , config =
              XML.text
              ''
              <config>
              	<parent-provides>
              		<service name="ROM"/>
              		<service name="PD"/>
              		<service name="RM"/>
              		<service name="CPU"/>
              		<service name="LOG"/>
              		<service name="Timer"/>
              		<service name="File_system"/>
              		<service name="Nitpicker"/>
              		<service name="Report"/>
              	</parent-provides>
              
              	<default-route> <any-service> <parent/> <any-child/> </any-service> </default-route>
              
              	<default caps="100"/>
              
              	<start name="nit_fb">
              		<resource name="RAM" quantum="4M"/>
              		<provides> <service name="Framebuffer"/> <service name="Input"/> </provides>
              		<config xpos="10" ypos="10" initial_width="800" initial_height="600"/>
              		<route>
              			<service name="Nitpicker"> <parent label="terminal"/> </service>
              			<any-service> <parent/> </any-service>
              		</route>
              	</start>
              
              	<start name="terminal">
              		<resource name="RAM" quantum="4M"/>
              		<provides> <service name="Terminal"/> </provides>
              		<config copy="yes" paste="yes">
              			<vfs> <dir name="fonts"> <fs/> </dir> </vfs>
              		</config>
              		<route>
              			<service name="File_system"> <parent label="fonts"/> </service>
              			<service name="Report" label="clipboard"> <parent label="clipboard"/> </service>
              			<service name="ROM"    label="clipboard"> <parent label="clipboard"/> </service>
              			<any-service> <parent/> <any-child/> </any-service>
              		</route>
              	</start>
              
              	<start name="noux" caps="500">
              		<resource name="RAM" quantum="60M" />
              		<exit propagate="yes"/>
              		<config>
              			<fstab>
              				<tar name="bash-minimal.tar" />
              				<tar name="coreutils-minimal.tar" />
              				<tar name="vim-minimal.tar" />
              				<dir name="dev"> <zero/> <null/> </dir>
              				<dir name="rw">     <fs label="target"/> </dir>
              				<dir name="report"> <fs label="report"/> </dir>
              				<dir name="config"> <fs label="config"/> </dir>
              				<dir name="tmp"> <ram /> </dir>
              			</fstab>
              			<start name="/bin/bash">
              				<env name="TERM" value="screen" />
              				<env name="PS1" value="noux:$PWD> " />
              			</start>
              		</config>
              		<route>
              			<service name="File_system" label="target"> <parent label="target"/> </service>
              			<service name="File_system" label="config"> <parent label="config"/> </service>
              			<service name="File_system" label="report"> <parent label="report"/> </service>
              			<service name="Terminal"> <child name="terminal"/> </service>
              			<any-service> <parent/> </any-service>
              		</route>
              	</start>
              </config>
                  ''
          }
    }
