Module Mirage_key

Mirage keys.

Release v3.8.0

module Arg : sig ... end
include Functoria.KEY with module Arg := Arg
type 'a value = 'a Functoria_key.value

The type for configure-time and run-time values. Values are either pure or obtained by composing other values. Values might have data dependencies, which form an (implicit) directed and acyclic graph that need to be evaluated.

val pure : 'a -> 'a value

pure x is a value without any dependency.

val ($) : ('a -> 'b) value -> 'a value -> 'b value

f $ v is is the value resulting from the application of f'value to v's value. $ is the usual app operator for applicative functor.

val map : ('a -> 'b) -> 'a value -> 'b value

map f v is pure f $ v.

val if_ : bool value -> 'a -> 'a -> 'a value

if_ v x y is map (fun b -> if b then x else y) v.

val match_ : 'a value -> ('a -> 'b) -> 'b value

match_ v pattern is map pattern v.

val default : 'a value -> 'a

default v returns the default value for v.

Configuration Keys

type 'a key = 'a Functoria_key.key

The type for configuration keys. Keys are used to retrieve the cross-stage values they are holding (by indexing contents in the autogenerated Bootgen_var module) but also to parameterize the choice of module implementation.

val create : string -> 'a Arg.t -> 'a key

create n a is the key named n whose contents is determined by parsing the command-line argument a.

val value : 'a key -> 'a value

value k is the value parsed by k.

The type for abstract keys.

module Set : sig ... end with type Set.t = Functoria_key.Set.t

Set implements sets over t elements.

val abstract : 'a key -> t

hide k is the k with its type hidden.

val equal : t -> t -> bool

equal is the equality function of untyped keys.

val hash : t -> int

hash is the hash function for untyped keys.

val compare : t -> t -> int

compare compares untyped keys.

val pp : t Fmt.t

pp fmt k prints the name of k.

val of_deps : Set.t -> unit value

of_deps keys is a value with keys as data-dependencies.

val deps : 'a value -> Set.t

deps v are v's data-dependencies.

val pp_deps : 'a value Fmt.t

pp_deps fmt v prints the name of the dependencies of v.

Stages

val is_runtime : t -> bool

is_runtime k is true if k's stage is `Run or `Both.

val is_configure : t -> bool

is_configure k is true if k's stage is `Configure or `Both.

val filter_stage : Arg.stage -> Set.t -> Set.t

filter_stage s ks is ks but with only keys available at stage s.

module Alias : sig ... end with type 'a Alias.t = 'a Functoria_key.Alias.t

Alias allows to define virtual keys in terms of other keys at configuration time only.

val alias : string -> 'a Alias.t -> 'a key

Similar to create but for command-line alias.

val aliases : t -> Set.t

aliases t is the list of t's aliases.

val name : t -> string

name t is the string given as t's name when t was created.

Parsing context

type context = Functoria_key.context

The type for values holding parsing context.

val dump_context : context Fmt.t

dump_context dumps the contents of a context.

val empty_context : context
val merge_context : default:context -> context -> context
val add_to_context : 'a key -> 'a -> context -> context

Add a binding to a context.

val context : ?⁠stage:Arg.stage -> with_required:bool -> Set.t -> context Cmdliner.Term.t

context ~with_required ks is a Cmdliner term that evaluates into a parsing context for command-line arguments. If with_required is false, it will only produce optional keys.

val mem : context -> 'a value -> bool

mem c v is true iff all the dependencies of v have been evaluated.

val peek : context -> 'a value -> 'a option

peek c v is Some x if mem v and None otherwise.

val eval : context -> 'a value -> 'a

eval c v evaluates v in c's context, using default values if necessary.

val get : context -> 'a key -> 'a

get c k is k's value in c's context.

val pps : context -> Set.t Fmt.t

pps c fmt ks prints the keys ks using the context c to get their value.

Code Serialization

val ocaml_name : t -> string

ocaml_name k is the ocaml name of k.

val serialize_call : t Fmt.t

serialize_call fmt k outputs Key_gen.n () to fmt, where n is k's OCaml name.

val serialize : context -> t Fmt.t

serialize ctx ppf k outputs the Cmdliner runes to parse command-line arguments represented by k at runtime.

type mode_unix = [
| `Unix
| `MacOSX
]
type mode_xen = [
| `Xen
| `Qubes
]
type mode_solo5 = [
| `Hvt
| `Spt
| `Virtio
| `Muen
| `Genode
]
type mode = [
| mode_unix
| mode_xen
| mode_solo5
]

Mirage keys

val target : mode key

-t TARGET: Key setting the configuration mode for the current project. Is one of "unix", "macosx", "xen", "qubes", "virtio", "hvt", "muen", "genode" or "spt".

val pp_target : mode Fmt.t

Pretty printer for the mode.

val is_unix : bool value

Is true iff the target key is a UNIXish system ("unix" or "macosx").

val is_solo5 : bool value

Is true iff the target key is a Solo5-based target.

val is_xen : bool value

Is true iff the target key is a Xen-based system ("xen" or "qubes").

val warn_error : bool key

--warn-error. Enable -warn-error for OCaml sources. Set to false by default, but might might enabled by default in later releases.

val target_debug : bool key

-g. Enables target-specific support for debugging.

val no_depext : bool key

--no-depext. Disables opam depext in depend target of generated Makefile.

val tracing_size : int -> int key

--tracing-size: Key setting the tracing ring buffer size.

Generic keys

File system keys

val kv_ro : ?⁠group:string -> unit -> [ `Archive | `Crunch | `Direct | `Fat ] key

The type of key value store. Is one of "archive", "crunch", "direct", or "fat".

val block : ?⁠group:string -> unit -> [ `XenstoreId | `BlockFile | `Ramdisk ] key

Block device keys

PRNG key

val prng : [ `Stdlib | `Nocrypto ] key

The type of pseudo random number generator to use by default.

Stack keys

val dhcp : ?⁠group:string -> unit -> bool key

Enable dhcp. Is either true or false.

val net : ?⁠group:string -> unit -> [ `Direct | `Socket ] option key

The type of stack. Is either "direct" or "socket".

Network keys

val interface : ?⁠group:string -> string -> string key

A network interface.

module V4 : sig ... end

Ipv4 keys.

module V6 : sig ... end

Ipv6 keys.

val resolver : ?⁠default:Ipaddr.V4.t -> unit -> Ipaddr.V4.t key

The address of the DNS resolver to use.

val resolver_port : ?⁠default:int -> unit -> int key

The port of the DNS resolver.

val syslog : Ipaddr.V4.t option -> Ipaddr.V4.t option key

The address to send syslog frames to.

val syslog_port : int option -> int option key

The port to send syslog frames to.

val syslog_hostname : string -> string key

The hostname to use in syslog frames.

val logs : Mirage_runtime.log_threshold list key