Mirage module syntax

I’m trying to write some mirage unikernel stuff currently. The issue is that I can’t seem to get the module names correct.

For example

module I = Static_ipv4.Make(Mirage_random_stdlib) (Mirage_clock.MCLOCK)

complains that MCLOCK doesn’t exist, nor does Mirage_clock.MCLOCK or Mirage_clock_unix.MCLOCK

I have both mirage-clock and mirage-clock-unix as libraries in the dune file, but seemingly can’t figure out how to actually access the module.

Additionally my merlin is giving me just the Mirage_clock.MCLOCK module, so I don’t know if it is steering me incorrectly in terms of giving me incorrect module information.

module I = Static_ipv4.Make(Mirage_random_stdlib) (Mirage_clock.MCLOCK)

Mirage_clock.MCLOCK is a signature. Then, the requested platform (eg. mirage-unix in your case) comes with an implementation mclock.cmx. So to apply correctly your functor, you should have:

module I = Static_ipv4.Make(Mirage_random_stdlib) (Mclock)

And mirage-clock-unix as a dependency. However, a mirage user should not do that by hands when functoria serves this purpose and apply correctly functor according the requested target and a description of your unikernel (by mirage configure -t unix).

So am I then confusing code which should be autogenerated by mirage with handwritten code?

I’m working on updating a legacy codebase so it may be that it was originally autogenerated then changed over time.

Thanks for clearing this up for me! Also do you know of any good resources on how to do mirage projects? I have only found bits and pieces in various repos, not anything cohesive.

Not sure if you’ve seen this already, but https://github.com/mirage/mirage-skeleton can be a good source for examples. It has quite a few examples that show how to setup various mirage devices.

1 Like