ocaml-flake

ocaml-flake uses opam-nix to build ocaml packages. The module structure is inspired by haskell-flake.

Since the flake is fairly new future versions may introduce breaking changes.

Installation

To initialize a new dune project using ocaml-flake simply run:

nix flake init -t github:9glenda/ocaml-flake#simple

This will set up a devshell and package for you.

Options

perSystem.ocaml

Ocaml module

Type: submodule

Default: { }

Declared by:

perSystem.ocaml.duneProjects

dune Projects.

Type: attribute set of (submodule)

Default: {}

Declared by:

perSystem.ocaml.duneProjects.<name>.autoWire

What will be added to the flake outputs.

Note for dev shells nix will create a dev shell from the default package in case no dev shell is specified.

Type: list of (one of “devShell”, “package”)

Default: ["devShell" "package"]

Declared by:

perSystem.ocaml.duneProjects.<name>.devShell.enable

Create a dev shell for the project. The devShell is located in ocaml.dunePackage.<name>.outputs.devShell. To automatically add the dev shell to the outputs of the flake add "devshell" to autoWire.

Type: boolean

Default: true

Declared by:

perSystem.ocaml.duneProjects.<name>.devShell.extraPackages

Extra packages to install into the dev shell alongside the opamPackages.

Type: list of package

Default: []

Declared by:

perSystem.ocaml.duneProjects.<name>.devShell.inputsFromPackage

Take inputs from the package.

Type: boolean

Default: true

Example: false

Declared by:

perSystem.ocaml.duneProjects.<name>.devShell.mkShellArgs

Extra arguments to pass to pkgs.mkShell.

The already set arguments get overwritten. It’s implemented like this:

  pkgs.mkShell ({ ... } // mkShellArgs)

Type: attribute set of raw value

Default: { }

Example:

''
  {
    shellHook = \'\'
      echo "example shell hook"
    \'\';
  };
''

Declared by:

perSystem.ocaml.duneProjects.<name>.devShell.name

name of the devShell

Type: string

Default: " development development shell"

Declared by:

perSystem.ocaml.duneProjects.<name>.devShell.opamPackages

development packages like the lsp and ocamlformat. Those packages get installed in the dev shell too. If the devShell is disabled this option will be ignored.

Type: attribute set of (null or string)

Default:

{
                  ocaml-lsp-server = "1.16.2";
                  ocamlformat = "0.26.1";
                  utop = "2.13.1";
                  ocamlfind = "1.9.6";
                }

Declared by:

perSystem.ocaml.duneProjects.<name>.name

name of the dune package. Defined in dune-project

Type: string

Default:

Declared by:

perSystem.ocaml.duneProjects.<name>.outputs.package

used internally

Type: null or package (read only)

Declared by:

perSystem.ocaml.duneProjects.<name>.outputs.devShell

used internally

Type: null or raw value (read only)

Declared by:

perSystem.ocaml.duneProjects.<name>.settings.opamPackages

opam packages like the base compiler

Type: attribute set of string

Default: { ocaml-base-compiler = "5.1.0"; }

Declared by:

perSystem.ocaml.duneProjects.<name>.settings.overlay

overlay applied to opam-nix

Type: raw value

Default: _: _: { }

Declared by:

perSystem.ocaml.duneProjects.<name>.settings.repos

opam repos

Type: list of raw value

Default: []

Declared by:

perSystem.ocaml.duneProjects.<name>.src

name of the dune package. Defined in dune-project

Type: path

Declared by:

perSystem.ocaml.inputs.opam-nix

opam-nix flake input

Type: raw value

Declared by:

perSystem.ocaml.inputs.opam-repository

opam-repository flake input

Type: raw value

Declared by:

perSystem.ocaml.inputs.treefmt

treefmt flake input

Type: raw value

Declared by: