Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ocamlPackages: Use lib.makeScope #53357

Merged
merged 1 commit into from Jan 6, 2019

Conversation

pukkamustard
Copy link
Contributor

@pukkamustard pukkamustard commented Jan 3, 2019

Motivation for this change

Simplify by using lib.makeScope (similar to #43104 and #33600).

Also stop exposing mkOcamlPackages as there is now a ocamlPackages.overrideScope' which can solve the use-case (#19605).

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@vbgl
Copy link
Contributor

vbgl commented Jan 5, 2019

Can you please explain how to override the OCaml compiler in the new setting (e.g., what to achieve what is described there: https://discourse.nixos.org/t/install-ocaml-flambda-compiler/1618/2). Thanks.

@pukkamustard
Copy link
Contributor Author

Can you please explain how to override the OCaml compiler in the new setting (e.g., what to achieve what is described there: https://discourse.nixos.org/t/install-ocaml-flambda-compiler/1618/2). Thanks.

oP = ocamlPackages.overrideScope' (self: super: {
    ocaml = super.ocaml.override { flambdaSupport = true; };
});

Things in ocamlPackages will be rebuilt with the overridden ocaml (if required).

A more complete example that uses nixpkgs overlays, overrides lwt4 and adds a custom OCaml package to ocamlPackages:

let
overlay = self: super: {
  ocamlPackages = super.ocamlPackages.overrideScope' (self: super: {

    ocaml = super.ocaml.override { flambdaSupport = true; };

    lwt4 = callPackage ./my_custom_lwt {};

    my_ocaml_package = callPackage ./my_ocaml_package {};

  });
};

in

with <nixpkgs> {
  overlays = [ overlay ];
};

ocamlPackages.buildDunePackage rec {
  pname = "an-ocaml-project";
  version = "1.0";

  minimumOCamlVersion = "4.03";

  src = ./.;

  buildInputs = with ocamlPackages; [ utop ];
  propagatedBuildInputs = with ocamlPackages;
    [ cohttp-lwt my_ocaml_package ];

}

This will give a build environment with overridden OCaml compiler, a custom lwt version and a custom package. Any packages that require lwt (cohttp-lwt) will use the custom version.

@vbgl vbgl merged commit 9211bcc into NixOS:master Jan 6, 2019
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/install-ocaml-flambda-compiler/1618/3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants