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.topkg: refactoring #32680

Merged
merged 2 commits into from Dec 15, 2017
Merged

Conversation

vbgl
Copy link
Contributor

@vbgl vbgl commented Dec 14, 2017

Motivation for this change

Factorize some code.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-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/)
  • Fits CONTRIBUTING.md.

@@ -13,14 +17,15 @@ stdenv.mkDerivation rec {
sha256 = "1slrzbmyp81xhgsfwwqs2d6gxzvqx0gcp34rq00h5iblhcq7myx6";
};

nativeBuildInputs = [ opam ];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conceptually this line should be left as is because it changes the opam used for cross compilation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m not sure to understand your comment. I removed this line because no opam stuff from the environment ($PATH) is used during the build. Instead, the absolute path to opam-installer is resolved by nix when evaluating the installPhase attribute.

I’ve no clue how cross-compilation works with nixpkgs but I guess it’s not just a matter of having opam for the build architecture: how to get an OCaml cross-compiler? how to run it alongside ocaml for the build architecture (to run the build system, itself written in OCaml)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that cross compilation for OCaml is not implemented in Nixpkgs, so there is no practical reason to keep this line, but the way it works is that during native compilation callPackage topkg/default.nix will be called once, and the value of nativeBuildInputs will have no effect on the value of opam, but during cross compilation it will be called again, with the value of nativeBuildInputs from the first call affecting the value of opam in the second call.

Copy link
Member

@Mic92 Mic92 Dec 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should solved later, when the cross-compiling stuff has landed in nixpkgs.

@@ -4,6 +4,10 @@ if !stdenv.lib.versionAtLeast ocaml.version "4.01"
then throw "topkg is not available for OCaml ${ocaml.version}"
else

let
run = "ocaml -I ${findlib}/lib/ocaml/${ocaml.version}/site-lib/ pkg/pkg.ml";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may want to leave a comment that run and buildPhase are part of the interface for use by other Ocaml packages and should be changed with care.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@orivej orivej merged commit e7d4784 into NixOS:master Dec 15, 2017
@vbgl
Copy link
Contributor Author

vbgl commented Dec 15, 2017

Thanks for the reviews.

@vbgl vbgl deleted the ocaml-topkg-cleanup branch December 15, 2017 17:48
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