about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVincent Laporte2024-11-08 08:31:01 +0100
committerVincent Laporte2024-11-15 06:48:53 +0100
commit0c76e226378533cfb67d691db631e098b944b90b (patch)
treed6e678de80c0cdf128d2af8dbd8c3694b3cadb7f
parentb1f444f47d40b95f6837dbb55b41b891ede31264 (diff)
reason: refactor
Move rtop to a separate package.

(cherry picked from commit a42c917e0a7337675271048f1b3b463373391a07)
-rw-r--r--pkgs/development/compilers/reason/default.nix40
-rw-r--r--pkgs/development/compilers/reason/rtop.nix25
-rw-r--r--pkgs/development/compilers/reason/tests/hello/default.nix3
-rw-r--r--pkgs/top-level/all-packages.nix2
-rw-r--r--pkgs/top-level/ocaml-packages.nix2
5 files changed, 39 insertions, 33 deletions
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,55 +1,36 @@
-{ 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;
+    merlin-extend
+  ];
 
   propagatedBuildInputs = [
+    ppxlib
     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
-  '';
-
   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 3c3f6e686541..0519ee38b00f 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -7684,7 +7684,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 ###