From a42c917e0a7337675271048f1b3b463373391a07 Mon Sep 17 00:00:00 2001 From: Vincent Laporte Date: Fri, 8 Nov 2024 08:31:01 +0100 Subject: [PATCH] reason: refactor Move rtop to a separate package. --- pkgs/development/compilers/reason/default.nix | 42 +++++-------------- pkgs/development/compilers/reason/rtop.nix | 25 +++++++++++ .../compilers/reason/tests/hello/default.nix | 3 +- pkgs/top-level/all-packages.nix | 2 +- pkgs/top-level/ocaml-packages.nix | 2 + 5 files changed, 40 insertions(+), 34 deletions(-) create mode 100644 pkgs/development/compilers/reason/rtop.nix diff --git a/pkgs/development/compilers/reason/default.nix b/pkgs/development/compilers/reason/default.nix index 99c0b6a99a25..89487bdaa362 100644 --- a/pkgs/development/compilers/reason/default.nix +++ b/pkgs/development/compilers/reason/default.nix @@ -1,54 +1,35 @@ -{ lib, callPackage, stdenv, makeWrapper, fetchurl, ocaml, findlib, dune_3 -, ncurses -, fix, menhir, menhirLib, menhirSdk, merlin-extend, ppxlib, utop, cppo, ppx_derivers +{ lib, callPackage, buildDunePackage, fetchurl +, fix, menhir, menhirLib, menhirSdk, merlin-extend, ppxlib, cppo, ppx_derivers , dune-build-info }: -stdenv.mkDerivation rec { - pname = "ocaml${ocaml.version}-reason"; +buildDunePackage rec { + pname = "reason"; version = "3.13.0"; + minimalOCamlVersion = "4.11"; + src = fetchurl { url = "https://github.com/reasonml/reason/releases/download/${version}/reason-${version}.tbz"; hash = "sha256-3yVEYGvIJKZwguIBGCbnoc3nrwzLW6RX6Tf+AYw85+Q="; }; - strictDeps = true; nativeBuildInputs = [ - makeWrapper - menhir - ocaml menhir cppo - dune_3 - findlib ]; buildInputs = [ dune-build-info fix menhirSdk - ppxlib - utop - ] ++ lib.optional (lib.versionOlder ocaml.version "4.07") ncurses; - - propagatedBuildInputs = [ - menhirLib merlin-extend - ppx_derivers ]; - buildFlags = [ "build" ]; # do not "make tests" before reason lib is installed - - installPhase = '' - runHook preInstall - dune install --prefix=$out --libdir=$OCAMLFIND_DESTDIR - wrapProgram $out/bin/rtop \ - --prefix PATH : "${utop}/bin" \ - --prefix CAML_LD_LIBRARY_PATH : "$CAML_LD_LIBRARY_PATH" \ - --prefix OCAMLPATH : "$OCAMLPATH:$OCAMLFIND_DESTDIR" - runHook postInstall - ''; + propagatedBuildInputs = [ + ppxlib + menhirLib + ]; passthru.tests = { hello = callPackage ./tests/hello { }; @@ -57,9 +38,8 @@ stdenv.mkDerivation rec { meta = with lib; { homepage = "https://reasonml.github.io/"; downloadPage = "https://github.com/reasonml/reason"; - description = "Facebook's friendly syntax to OCaml"; + description = "User-friendly programming language built on OCaml"; license = licenses.mit; - inherit (ocaml.meta) platforms; maintainers = [ ]; }; } diff --git a/pkgs/development/compilers/reason/rtop.nix b/pkgs/development/compilers/reason/rtop.nix new file mode 100644 index 000000000000..0255e57d5c47 --- /dev/null +++ b/pkgs/development/compilers/reason/rtop.nix @@ -0,0 +1,25 @@ +{ buildDunePackage, reason, cppo, utop, makeWrapper }: + +buildDunePackage { + pname = "rtop"; + inherit (reason) version src; + + nativeBuildInputs = [ + makeWrapper + cppo + ]; + + propagatedBuildInputs = [ reason utop ]; + + postInstall = '' + wrapProgram $out/bin/rtop \ + --prefix PATH : "${utop}/bin" \ + --prefix CAML_LD_LIBRARY_PATH : "$CAML_LD_LIBRARY_PATH" \ + --prefix OCAMLPATH : "$OCAMLPATH:$OCAMLFIND_DESTDIR" + ''; + + meta = reason.meta // { + description = "Toplevel (or REPL) for Reason, based on utop"; + mainProgram = "rtop"; + }; +} diff --git a/pkgs/development/compilers/reason/tests/hello/default.nix b/pkgs/development/compilers/reason/tests/hello/default.nix index 831b528c6ba9..42a0173a03be 100644 --- a/pkgs/development/compilers/reason/tests/hello/default.nix +++ b/pkgs/development/compilers/reason/tests/hello/default.nix @@ -1,4 +1,4 @@ -{ lib, buildDunePackage, ppxlib, reason }: +{ lib, buildDunePackage, reason }: buildDunePackage rec { pname = "helloreason"; @@ -19,7 +19,6 @@ buildDunePackage rec { ]; buildInputs = [ - ppxlib reason ]; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 89a2923133ad..b4034e5937f2 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -7682,7 +7682,7 @@ with pkgs; nqp = callPackage ../development/interpreters/rakudo/nqp.nix { }; zef = callPackage ../development/interpreters/rakudo/zef.nix { }; - inherit (ocamlPackages) reason; + inherit (ocamlPackages) reason rtop; buildRubyGem = callPackage ../development/ruby-modules/gem { inherit (darwin) libobjc; diff --git a/pkgs/top-level/ocaml-packages.nix b/pkgs/top-level/ocaml-packages.nix index 2f0ce2558934..6f244496f514 100644 --- a/pkgs/top-level/ocaml-packages.nix +++ b/pkgs/top-level/ocaml-packages.nix @@ -1691,6 +1691,8 @@ let rresult = callPackage ../development/ocaml-modules/rresult { }; + rtop = callPackage ../development/compilers/reason/rtop.nix { }; + rusage = callPackage ../development/ocaml-modules/rusage { }; ### S ###