# Install Ocaml+flambda compiler

**URL:** https://discourse.nixos.org/t/install-ocaml-flambda-compiler/1618
**Category:** Help
**Created:** [December 7, 2018, 3:29am UTC](https://discourse.nixos.org/t/install-ocaml-flambda-compiler/1618 "2018-12-07T03:29:12Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Amar1729](https://discourse.nixos.org/user_avatar/discourse.nixos.org/amar1729/32/768_2.png) [@Amar1729](https://discourse.nixos.org/u/Amar1729)
#### Post date: [December 7, 2018, 3:29am UTC](https://discourse.nixos.org/t/install-ocaml-flambda-compiler/1618/1 "2018-12-07T03:29:12Z")

</div>

I’m currently trying to build a nix expression for a static analysis tool, [infer](https://github.com/facebook/infer), that has many opam dependencies relying on the ocaml 4.06.1+flambda compiler. Is there a way to install the ocaml+flambda compiler straight from nix rather than compiling it? Currently, I have:

```auto
buildInputs = [ocaml opam_1_2 ...];
postUnpack = ""
opam init
opam switch 4.06.1+flambda
"";

```

But manually calling `opam switch` to configure ocaml can be time-consuming while I’m trying to build.

---

<div class="post-metadata">

### Author: ![vbgl](https://discourse.nixos.org/user_avatar/discourse.nixos.org/vbgl/32/128_2.png) [@vbgl](https://discourse.nixos.org/u/vbgl)
#### Post date: [December 7, 2018, 8:21pm UTC](https://discourse.nixos.org/t/install-ocaml-flambda-compiler/1618/2 "2018-12-07T20:21:15Z")

</div>

To get OCaml with `flambda` enabled, you can call the `ocaml` package with the argument `flambdaSupport = true`. Then you can build the set of OCaml packages corresponding to this compiler (using `ocaml-ng.mkOcamlPackages`). Example:

```auto
let o = ocaml.override { flambdaSupport = true; }; in
let oP = ocaml-ng.mkOcamlPackages o (self: super: {}); in
oP.apron

```

Some dependencies of `infer` may be missing. Thanks for your contribution!

---

<div class="post-metadata">

### Author: ![573](https://discourse.nixos.org/user_avatar/discourse.nixos.org/573/32/2640_2.png) [@573](https://discourse.nixos.org/u/573)
#### Post date: [April 28, 2023, 9:14am UTC](https://discourse.nixos.org/t/install-ocaml-flambda-compiler/1618/3 "2023-04-28T09:14:47Z")

</div>

Update to your solution: See [OCaml - NixOS Wiki](https://nixos.wiki/wiki/OCaml#Custom_version) (due to [ocamlPackages: Use lib.makeScope by pukkamustard · Pull Request #53357 · NixOS/nixpkgs · GitHub](https://github.com/NixOS/nixpkgs/pull/53357#issuecomment-451727433)).
