2
0
Fork 0
Genode Packages collection https://git.sr.ht/~ehmry/genodepkgs/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
genodepkgs/nixos-modules/systemd-runner.dhall

154 lines
5.9 KiB

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, 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 = "bash"
, 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"
, rtc = Some "/dev/rtc"
, socket = Some "/dev/sockets"
, vfs = [ VFS.leaf "fs" ]
, args = 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::{=}