package mirage

  1. Overview
  2. Docs

Command-line arguments for the Mirage configuration tool.

include module type of Functoria.Key
module Arg = Functoria.Key.Arg

Configuration Keys

type 'a key = 'a Functoria.Key.key

The type for configuration keys. Keys are used 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.

Configuration Values

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.

val value : 'a key -> 'a value

value k is the value parsed by k.

Abstract Keys

The type for abstract keys.

val name : t -> string

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

val v : 'a key -> t

v k is the k with its type hidden.

val equal : t -> t -> bool

equal is the equality function of untyped keys.

val pp : t Fmt.t

pp fmt k prints the name of k.

module Set = Functoria.Key.Set

Set implements sets over t elements.

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.

Parsing context

type context := Functoria.Context.t

The type for values holding parsing context.

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

Add a binding to a context.

val context : Set.t -> context Cmdliner.Term.t

context ks is a Cmdliner term that evaluates into a parsing context for command-line arguments.

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. If k is not present in c, it is k's default value.

val find : context -> 'a key -> 'a option

find c k is k's value in c's context or None if k is not present in c.

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

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

type mode_unix = [
  1. | `Unix
  2. | `MacOSX
]
type mode_xen = [
  1. | `Xen
  2. | `Qubes
]
type mode_solo5 = [
  1. | `Hvt
  2. | `Spt
  3. | `Virtio
  4. | `Muen
  5. | `Genode
]
type mode = [
  1. | mode_unix
  2. | mode_xen
  3. | 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").

Generic keys

Some keys have a group optional argument. This group argument allows to give several keys a prefix.

For example, if we have two ip stacks, one external and one internal, We can use the group option to name them in and out. This way, the available keys will be --in-ip and --out-ip.

If a key has another, non-optional argument. It is the default value.

Keys are always named the same as their command line option.

File system keys

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

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

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

Block device keys

Stack keys

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

Enable dhcp. Is either true or false.

val net : ?group:string -> unit -> [ `OCaml | `Host ] option key

The type of stack. Is either "ocaml" or "host".

OCaml

Innovation. Community. Security.