Skip to content

Commit f6d6c37

Browse files
authored
Merge pull request #569 from pq-code-package/hol_light_interactive
HOL-Light: Allow interactive use of hol.sh in the hol_light shell
2 parents d25a7d1 + 5325888 commit f6d6c37

File tree

5 files changed

+80
-44
lines changed

5 files changed

+80
-44
lines changed

flake.nix

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,17 @@
9393
inherit (pkgs) gcc-arm-embedded qemu coreutils python3 git;
9494
};
9595
};
96-
devShells.hol_light = util.mkShell {
96+
devShells.hol_light = (util.mkShell {
9797
packages = builtins.attrValues {
98-
inherit (config.packages) hol_light s2n_bignum;
98+
inherit (config.packages) linters hol_light s2n_bignum;
9999
};
100-
};
100+
}).overrideAttrs (old: {
101+
shellHook = ''
102+
export PATH=$PWD/scripts:$PATH
103+
# Set PROOF_DIR_ARM based on where we entered the shell
104+
export PROOF_DIR_ARM="$PWD/proofs/hol_light/arm"
105+
'';
106+
});
101107
devShells.ci = util.mkShell {
102108
packages = builtins.attrValues { inherit (config.packages) linters toolchains_native; };
103109
};
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
2+
diff --git a/hol_4.14.sh b/hol_4.14.sh
3+
index 1311255..8b2bc36 100755
4+
--- a/hol_4.14.sh
5+
+++ b/hol_4.14.sh
6+
@@ -5,7 +5,7 @@ export HOLLIGHT_DIR=__DIR__
7+
8+
if [ "$#" -eq 1 ]; then
9+
if [ "$1" == "-pp" ]; then
10+
- echo "camlp5r pa_lexer.cmo pa_extend.cmo q_MLast.cmo -I "__DIR__" pa_j.cmo"
11+
+ echo "camlp5r pa_lexer.cmo pa_extend.cmo q_MLast.cmo -I ${HOLLIGHT_DIR} pa_j.cmo"
12+
exit 0
13+
elif [ "$1" == "-dir" ]; then
14+
echo "${HOLLIGHT_DIR}"
15+
@@ -32,4 +32,13 @@ if [ "${HOL_ML_PATH}" == "" ]; then
16+
HOL_ML_PATH="${HOLLIGHT_DIR}/hol.ml"
17+
fi
18+
19+
-${LINE_EDITOR} ${HOLLIGHT_DIR}/ocaml-hol -init ${HOL_ML_PATH} -I ${HOLLIGHT_DIR}
20+
+# Add site-lib directory for topfind
21+
+SITELIB=$(dirname $(ocamlfind query findlib 2>/dev/null) 2>/dev/null)
22+
+
23+
+# Set HOLLIGHT_LOAD_PATH to include S2N_BIGNUM_DIR and mldsa-native proofs
24+
+export HOLLIGHT_LOAD_PATH="${S2N_BIGNUM_DIR}:${PROOF_DIR_ARM}:${HOLLIGHT_LOAD_PATH}"
25+
+
26+
+# Change to mldsa-native proofs directory if set, so define_from_elf can find object files
27+
+[ -n "${PROOF_DIR_ARM}" ] && cd "${PROOF_DIR_ARM}"
28+
+
29+
+${LINE_EDITOR} ${HOLLIGHT_DIR}/ocaml-hol -init ${HOL_ML_PATH} -I ${HOLLIGHT_DIR} ${SITELIB:+-I "$SITELIB"}
30+
diff --git a/hol_4.sh b/hol_4.sh
31+
index 0aaa5c7..5adaf4c 100755
32+
--- a/hol_4.sh
33+
+++ b/hol_4.sh
34+
@@ -5,7 +5,7 @@ export HOLLIGHT_DIR=__DIR__
35+
36+
if [ "$#" -eq 1 ]; then
37+
if [ "$1" == "-pp" ]; then
38+
- echo "camlp5r pa_lexer.cmo pa_extend.cmo q_MLast.cmo -I "__DIR__" pa_j.cmo"
39+
+ echo "camlp5r pa_lexer.cmo pa_extend.cmo q_MLast.cmo -I "${HOLLIGHT_DIR}" pa_j.cmo"
40+
exit 0
41+
elif [ "$1" == "-dir" ]; then
42+
echo "${HOLLIGHT_DIR}"
43+
@@ -32,4 +32,4 @@ if [ "${HOL_ML_PATH}" == "" ]; then
44+
HOL_ML_PATH="${HOLLIGHT_DIR}/hol.ml"
45+
fi
46+
47+
-${LINE_EDITOR} ${HOLLIGHT_DIR}/ocaml-hol -I `camlp5 -where` camlp5o.cma -init ${HOL_ML_PATH} -safe-string -I ${HOLLIGHT_DIR}
48+
+${LINE_EDITOR} ${HOLLIGHT_DIR}/ocaml-hol -I $(camlp5 -where) camlp5o.cma -init ${HOL_ML_PATH} -safe-string -I ${HOLLIGHT_DIR}

nix/hol_light/0005-Fix-hollight-path.patch

Lines changed: 0 additions & 35 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
2+
diff --git a/Makefile b/Makefile
3+
index abc1234..def5678 100644
4+
--- a/Makefile
5+
+++ b/Makefile
6+
@@ -100,7 +100,7 @@ hol.sh: pa_j.cmo ${HOLSRC} bignum.cmo hol_loader.cmo update_database.ml
7+
if [ `uname` = "Linux" ] || [ `uname` = "Darwin" ] ; then \
8+
if [ ${OCAML_UNARY_VERSION} = "5" ] || [ ${OCAML_VERSION} = "4.14" ] ; then \
9+
- ocamlfind ocamlmktop -package zarith -o ocaml-hol zarith.cma bignum.cmo hol_loader.cmo ; \
10+
+ ocamlfind ocamlmktop -package zarith,findlib -o ocaml-hol zarith.cma bignum.cmo hol_loader.cmo ; \
11+
sed "s^__DIR__^`pwd`^g; s^__USE_MODULE__^$(HOLLIGHT_USE_MODULE)^g" hol_4.14.sh > hol.sh ; \
12+
else \
13+
ocamlmktop -o ocaml-hol nums.cma bignum.cmo hol_loader.cmo ; \

nix/hol_light/default.nix

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,25 @@
22
# Copyright (c) The mldsa-native project authors
33
# SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
44

5-
{ hol_light, fetchFromGitHub, writeText, ... }:
5+
{ hol_light, fetchFromGitHub, writeText, ocamlPackages, ledit, ... }:
66
hol_light.overrideAttrs (old: {
77
setupHook = writeText "setup-hook.sh" ''
88
export HOLDIR="$1/lib/hol_light"
99
export HOLLIGHT_DIR="$1/lib/hol_light"
10+
export PATH="$1/lib/hol_light:$PATH"
1011
'';
11-
version = "unstable-2024-12-22";
12+
version = "unstable-2025-09-22";
1213
src = fetchFromGitHub {
1314
owner = "jrh13";
1415
repo = "hol-light";
15-
rev = "0e4b1bd8c7d400214d6fa6027f15a4221b54f8d4";
16-
hash = "sha256-M6ddzqoAFyMBmaznuz31+o035xdEz4VXZMHhH4Dm4c8=";
16+
rev = "bed58fa74649fa74015176f8f90e77f7af5cf8e3";
17+
hash = "sha256-QDubbUUChvv04239BdcKPSU+E2gdSzqAWfAETK2Xtg0=";
1718
};
18-
patches = [ ./0005-Fix-hollight-path.patch ];
19-
propagatedBuildInputs = old.propagatedBuildInputs ++ old.nativeBuildInputs;
19+
patches = [
20+
./0005-Configure-hol-sh-for-mldsa-native.patch
21+
./0006-Add-findlib-to-ocaml-hol.patch
22+
];
23+
propagatedBuildInputs = old.propagatedBuildInputs ++ old.nativeBuildInputs ++ [ ocamlPackages.pcre2 ledit ];
2024
buildPhase = ''
2125
HOLLIGHT_USE_MODULE=1 make hol.sh
2226
patchShebangs hol.sh

0 commit comments

Comments
 (0)