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 { lib, callPackage, buildDunePackage, fetchurl
, ncurses , fix, menhir, menhirLib, menhirSdk, merlin-extend, ppxlib, cppo, ppx_derivers
, fix, menhir, menhirLib, menhirSdk, merlin-extend, ppxlib, utop, cppo, ppx_derivers
, dune-build-info , dune-build-info
}: }:
stdenv.mkDerivation rec { buildDunePackage rec {
pname = "ocaml${ocaml.version}-reason"; pname = "reason";
version = "3.13.0"; version = "3.13.0";
minimalOCamlVersion = "4.11";
src = fetchurl { src = fetchurl {
url = "https://github.com/reasonml/reason/releases/download/${version}/reason-${version}.tbz"; url = "https://github.com/reasonml/reason/releases/download/${version}/reason-${version}.tbz";
hash = "sha256-3yVEYGvIJKZwguIBGCbnoc3nrwzLW6RX6Tf+AYw85+Q="; hash = "sha256-3yVEYGvIJKZwguIBGCbnoc3nrwzLW6RX6Tf+AYw85+Q=";
}; };
strictDeps = true;
nativeBuildInputs = [ nativeBuildInputs = [
makeWrapper
menhir
ocaml
menhir menhir
cppo cppo
dune_3
findlib
]; ];
buildInputs = [ buildInputs = [
dune-build-info dune-build-info
fix fix
menhirSdk menhirSdk
ppxlib
utop
] ++ lib.optional (lib.versionOlder ocaml.version "4.07") ncurses;
propagatedBuildInputs = [
menhirLib
merlin-extend merlin-extend
ppx_derivers
]; ];
buildFlags = [ "build" ]; # do not "make tests" before reason lib is installed propagatedBuildInputs = [
ppxlib
installPhase = '' menhirLib
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 = { passthru.tests = {
hello = callPackage ./tests/hello { }; hello = callPackage ./tests/hello { };
@ -57,9 +38,8 @@ stdenv.mkDerivation rec {
meta = with lib; { meta = with lib; {
homepage = "https://reasonml.github.io/"; homepage = "https://reasonml.github.io/";
downloadPage = "https://github.com/reasonml/reason"; downloadPage = "https://github.com/reasonml/reason";
description = "Facebook's friendly syntax to OCaml"; description = "User-friendly programming language built on OCaml";
license = licenses.mit; license = licenses.mit;
inherit (ocaml.meta) platforms;
maintainers = [ ]; 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 { buildDunePackage rec {
pname = "helloreason"; pname = "helloreason";
@ -19,7 +19,6 @@ buildDunePackage rec {
]; ];
buildInputs = [ buildInputs = [
ppxlib
reason reason
]; ];

View File

@ -7682,7 +7682,7 @@ with pkgs;
nqp = callPackage ../development/interpreters/rakudo/nqp.nix { }; nqp = callPackage ../development/interpreters/rakudo/nqp.nix { };
zef = callPackage ../development/interpreters/rakudo/zef.nix { }; zef = callPackage ../development/interpreters/rakudo/zef.nix { };
inherit (ocamlPackages) reason; inherit (ocamlPackages) reason rtop;
buildRubyGem = callPackage ../development/ruby-modules/gem { buildRubyGem = callPackage ../development/ruby-modules/gem {
inherit (darwin) libobjc; inherit (darwin) libobjc;

View File

@ -1691,6 +1691,8 @@ let
rresult = callPackage ../development/ocaml-modules/rresult { }; rresult = callPackage ../development/ocaml-modules/rresult { };
rtop = callPackage ../development/compilers/reason/rtop.nix { };
rusage = callPackage ../development/ocaml-modules/rusage { }; rusage = callPackage ../development/ocaml-modules/rusage { };
### S ### ### S ###