reason: refactor

Move rtop to a separate package.
This commit is contained in:
Vincent Laporte 2024-11-08 08:31:01 +01:00 committed by Vincent Laporte
parent fc74a00f3c
commit a42c917e0a
5 changed files with 40 additions and 34 deletions

View File

@ -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 = [ ];
};
}

View File

@ -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";
};
}

View File

@ -1,4 +1,4 @@
{ lib, buildDunePackage, ppxlib, reason }:
{ lib, buildDunePackage, reason }:
buildDunePackage rec {
pname = "helloreason";
@ -19,7 +19,6 @@ buildDunePackage rec {
];
buildInputs = [
ppxlib
reason
];

View File

@ -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;

View File

@ -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 ###