From 32a6049ad5fc6d418a1b193310078b3ab25993de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Basile=20Cl=C3=A9ment?= Date: Fri, 22 Nov 2024 14:51:13 +0100 Subject: [PATCH] ocamlPackages.menhir: support --suggest-menhirLib menhir provides a `--suggest-menhirLib` option that tries to infer the path of the menhir library from the path of the menhir binary. Since the menhir library and the menhir binary are built as different derivations, this does not work. This patch hardcodes the location of the menhir library into the menhir binary, making `--suggest-menhirLib` work. --- .../ocaml-modules/menhir/default.nix | 9 ++++++++- .../menhir/menhir-suggest-menhirLib.patch | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 pkgs/development/ocaml-modules/menhir/menhir-suggest-menhirLib.patch diff --git a/pkgs/development/ocaml-modules/menhir/default.nix b/pkgs/development/ocaml-modules/menhir/default.nix index afe2d5cf593a..04e80d69ebd0 100644 --- a/pkgs/development/ocaml-modules/menhir/default.nix +++ b/pkgs/development/ocaml-modules/menhir/default.nix @@ -1,4 +1,4 @@ -{ buildDunePackage +{ buildDunePackage, substituteAll, ocaml , menhirLib, menhirSdk }: @@ -11,6 +11,13 @@ buildDunePackage rec { buildInputs = [ menhirLib menhirSdk ]; + patches = [ + (substituteAll { + src = ./menhir-suggest-menhirLib.patch; + libdir = "${menhirLib}/lib/ocaml/${ocaml.version}/site-lib/menhirLib"; + }) + ]; + meta = menhirSdk.meta // { description = "LR(1) parser generator for OCaml"; mainProgram = "menhir"; diff --git a/pkgs/development/ocaml-modules/menhir/menhir-suggest-menhirLib.patch b/pkgs/development/ocaml-modules/menhir/menhir-suggest-menhirLib.patch new file mode 100644 index 000000000000..e580d5d7aaa8 --- /dev/null +++ b/pkgs/development/ocaml-modules/menhir/menhir-suggest-menhirLib.patch @@ -0,0 +1,19 @@ +diff --git a/src/installation.ml b/src/installation.ml +index 3c64e395..be7d6e7b 100644 +--- a/src/installation.ml ++++ b/src/installation.ml +@@ -39,13 +39,4 @@ let rec normalize fn = + and hope that it is of the form [.../bin/menhir]. We change this to + [.../lib/menhirLib], and hope that this is where MenhirLib is installed. *) + +-let libdir () = +- let root = +- Sys.executable_name +- |> normalize +- |> Filename.dirname (* remove [menhir] *) +- |> Filename.dirname (* remove [bin] *) +- in +- Filename.concat +- root +- (Filename.concat "lib" "menhirLib") ++let libdir () = ignore normalize; "@libdir@"