let Genode = env:DHALL_GENODE

let XML = Genode.Prelude.XML

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

let config =
        λ ( url
          : Text
          )
      → { ram =
            Genode.units.MiB 32
        , caps =
            768
        , requires =
            [ service "audio_out"
            , service "nic"
            , service "report"
            , service "rm"
            , service "rtc"
            ]
        , roms =
            [ "icy_client"
            , "init"
            , "libc.lib.so"
            , "libm.lib.so"
            , "libmpg123.lib.so"
            , "mp3_audio_sink"
            , "vfs.lib.so"
            , "vfs_lwip.lib.so"
            , "zlib.lib.so"
            ]
        , config =
            XML.text
            ''
            <config>
            	<parent-provides>
            		<service name="CPU"/>
            		<service name="LOG"/>
            		<service name="PD"/>
            		<service name="RM"/>
            		<service name="ROM"/>
            		<service name="Audio_out"/>
            		<service name="Timer"/>
            		<service name="Nic"/>
            		<service name="Report"/>
               		<service name="Rtc"/>
         	</parent-provides>
            	<start name="icy_client" caps="512">
            		<resource name="RAM" quantum="16M"/>
            		<config>
            			<stream url="${url}" dest="/terminal" report="yes"/>
            			<libc stderr="/log" stdout="/log" socket="/socket" rtc="/rtc" rng="/rtc"/>
            			<vfs>
            				<dir name="socket"> <lwip dhcp="yes"/> </dir>
            				<log/>
            				<rtc/>
            				<terminal/>
            			</vfs>
            		</config>
            		<route>
            			<any-service> <parent/> <any-child/> </any-service>
            		</route>
            	</start>
            
            	<start name="mp3_audio_sink" caps="256">
            		<resource name="RAM" quantum="8M"/>
            		<provides>
            			<service name="Terminal"/>
            		</provides>
            		<config>
            			<vfs> <null/> </vfs>
            			<libc stdout="/null" stderr="/null"/>
            		</config>
            		<route>
            			<any-service> <parent/> </any-service>
            		</route>
            	</start>
            </config>
            ''
        }

in  λ(url : Text) → { runtime = Genode.Runtime.defaults // (config url) }
