[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[MirageOS-devel] Patches for building mirage libraries with `opam2nix`

Hi all,

A little while ago I managed to get mirage's xen libraries and
dependencies building in nix [0]. This worked, but I didn't fancy
keeping those packages up to date manually. So I also started working
on `opam2nix`[1], a tool which generates nix expressions from an opam
repository. It's still work in progress, but has managed to build most
things I've thrown at it so far.

The main problem is when build scripts assume that they'll be
installed into `opam config var prefix`/lib/<library>, or that
pkgconfig specs will be found in `opam config var
prefix`/lib/pkgconfig. In the case of `opam2nix`, dependencies can be
found via `ocamlfind query`, while the destination will be a
completely different path which is populated in $PREFIX,
$OCAMLFIND_DESTDIR and opam variables (like %{lib}% etc.)

I've made a number of changes to make these build scripts more lenient
- e.g. rather than always overriding $PKG_CONFIG_PATH, they'll only do
that if all needed dependencies aren't already present. And also
respecting $PREFIX if it's set (but falling back to `opam config var
prefix` if not):




(note: the second of those two commits
[6121921ef6e666f021a61f3570840108927f90d8] removes something that I
_think_ was unnecessary, but it's worth verifying that with someone
who knows more about how the libraries depend on each other)


I had to rewrite the zarith-xen build script, because I couldn't come
up with a simple enough change which would support both the `opam` and
`opam2nix` cases. So this is less of a patch than a note that it
doesn't currently work, and maybe someone will have better ideas about
how to make it work:


It'd be great if the maintainers of these libraries are happy to merge
my changes, or otherwise discuss other ways of making these libraries
build in an I-can't-believe-it's-not-opam environment ;). I thought
I'd discuss it here rather than creating individual pull requests,
because this should provide a lot more context.

The main downside is that these changes make debugging a little
trickier, since the build scripts are slightly more complex. Also, it
might mean that a dependency could be picked up from a system package
rather than from `opam`.

It may also be a better idea in general to just feed more information
to the scripts directly from the `opam` file (via %{lib}% and friends)
rather than have them assume too much about how they'll be installed.
I didn't want to go down this route because it makes for more drastic
changes, but I'm happy to try it if you're game.

 - Tim.

[0]: http://nixos.org/nix/
[1]: https://github.com/gfxmonk/opam2nix/

MirageOS-devel mailing list



Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.