2
0
Fork 0
genodepkgs/nixos-modules/systemd-runner.dhall

160 lines
6.0 KiB
Plaintext

let Genode = env:DHALL_GENODE
let Prelude = Genode.Prelude
let XML = Prelude.XML
let Libc = Genode.Libc
let VFS = Genode.VFS
let Init = Genode.Init
let Child = Init.Child
let parentRoutes =
Prelude.List.map Text Init.ServiceRoute.Type Init.ServiceRoute.parent
in λ ( params
: { args : List Text
, binary : Text
, coreutils : Text
, interface : Optional Text
}
) →
let socketsVfs =
merge
{ Some =
λ(interface : Text) →
[ VFS.dir
"sockets"
[ VFS.fs VFS.FS::{ label = "${interface}.sockets" } ]
]
, None = [] : List XML.Type
}
params.interface
let init =
Init::{
, routes = parentRoutes [ "Timer", "Rtc", "File_system" ]
, children = toMap
{ vfs =
Child.flat
Child.Attributes::{
, binary = "vfs"
, exitPropagate = True
, provides = [ "File_system" ]
, resources = Genode.Init.Resources::{
, caps = 256
, ram = Genode.units.MiB 8
}
, config = Init.Config::{
, content =
[ VFS.vfs
[ VFS.dir
"dev"
( [ VFS.dir "pipes" [ VFS.leaf "pipe" ]
, VFS.leaf "log"
, VFS.leaf "null"
, VFS.leaf "rtc"
, VFS.leaf "zero"
]
# socketsVfs
)
, VFS.dir
"usr"
[ VFS.dir
"bin"
[ VFS.symlink
"env"
"${params.coreutils}/bin/env"
]
]
, VFS.dir "tmp" [ VFS.leaf "ram" ]
, VFS.dir
"nix"
[ VFS.dir
"store"
[ VFS.fs VFS.FS::{ label = "nix-store" } ]
]
]
]
, policies =
[ Init.Config.Policy::{
, service = "File_system"
, label = Init.LabelSelector.prefix "ExecStart"
, attributes = toMap
{ root = "/", writeable = "yes" }
}
, Init.Config.Policy::{
, service = "File_system"
, label = Init.LabelSelector.prefix "vfs_rom"
, attributes = toMap
{ root = "/", writeable = "yes" }
}
]
}
}
, vfs_rom =
Child.flat
Child.Attributes::{
, binary = "cached_fs_rom"
, provides = [ "ROM" ]
, resources = Genode.Init.Resources::{
, ram = Genode.units.MiB 16
}
, config = Init.Config::{
, policies =
[ Init.Config.Policy::{
, service = "ROM"
, diag = Some True
, label = Init.LabelSelector.prefix "ExecStart"
}
]
}
}
, ExecStart =
Child.flat
Child.Attributes::{
, binary = params.binary
, exitPropagate = True
, resources = Genode.Init.Resources::{
, caps = 256
, ram = Genode.units.MiB 8
}
, config =
( Libc.toConfig
Libc::{
, stdin = Some "/dev/null"
, stdout = Some "/dev/log"
, stderr = Some "/dev/log"
, pipe = Some "/dev/pipes"
, rng = Some "/dev/random"
, rtc = Some "/dev/rtc"
, socket = Some "/dev/sockets"
, vfs = [ VFS.leaf "fs" ]
, args = [ params.binary ] # params.args
}
)
with attributes = toMap { ld_verbose = "yes" }
, routes =
Prelude.List.map
Text
Init.ServiceRoute.Type
( λ(label : Text) →
Init.ServiceRoute.parentLabel
"ROM"
(Some label)
(Some label)
)
[ "libc.lib.so"
, "libm.lib.so"
, "posix.lib.so"
, "vfs.lib.so"
]
}
}
}
in Init.toChild init Init.Attributes::{=}