Giter VIP home page Giter VIP logo

opam-nix's Introduction

opam-nix

Turn opam-based OCaml projects into Nix derivations, automatically resolving both OCaml and system dependencies.

opam-nix can build packages

  • from opam and dune-project files,
  • for Linux and macOS,
  • on x86_64 and aarch64 (including M1 macs),
  • using a compiler from nixpkgs or from opam-repository,
  • with either dynamic or static linking.

It also comes with the power of Nix, allowing you to effortlessly manage multiple projects with different dependency versions, override dependencies, cache builds, and more.

Quick start

For a quick introduction to opam-nix and a guide to get you started, read this blog post on the Tweag blog.

Templates

opam-nix comes with some templates that can help you package opam packages with Nix.

Note

All of these templates assume that you already have an OCaml project packaged with opam, and just want to package it with Nix. If you're starting from scratch, you have to set up the opam files separately.

  • A simple package build, no frills: nix flake init -t github:tweag/opam-nix
  • A more featured flake, building an executable and providing a shell in which you can conveniently work on it: nix flake init -t github:tweag/opam-nix#executable
  • Build multiple packages from the same workspace, and have a shell in which you can work on them: nix flake init -t github:tweag/opam-nix#multi-package

Note

If you're using Git, you should git add flake.nix after initializing, as Nix operates on the git index contents.

Examples

There are also some examples which can give you some ideas of what is possible with opam-nix:

All examples are checks and packages, so you can do e.g. nix build github:tweag/opam-nix#opam-ed to try them out individually, or nix flake check github:tweag/opam-nix to build them all.

Building packages from opam-repository with Nix

opam-nix provides all packages from opam-repository in its legacyPackages flake output. You can use this to quickly check out some package, or get a shell with particular version without messing with opam switches.

For example:

  • nix build 'github:tweag/opam-nix#utop."2.10.0"' to build a specific version of utop (available in ./result),
  • nix shell github:tweag/opam-nix#camyll.latest to get a shell with the latest version of camyll.

Complete documentation

Complete documentation for opam-nix is available in the DOCUMENTATION.md file.

Questions? Problems?

You can reach out to us via the Discussions page or directly to the maintainer via email.

Related projects

  • Nix: A powerful package manager that makes package management reliable and reproducible;
  • opam: the OCaml package manager;
  • hillingar: Tool for building MirageOS unikernels with opam-nix.

opam-nix's People

Contributors

balsoft avatar rizo avatar niols avatar actionshrimp avatar julow avatar ryangibb avatar arvidj avatar bclement-ocp avatar djacu avatar henrytill avatar logicaloverflow avatar garbas avatar yorickvp avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.