From abecc6115041edef84d90b9ed600a853cfe8ddea Mon Sep 17 00:00:00 2001 From: Ethan Carter Edwards Date: Sun, 8 Jun 2025 18:37:55 -0400 Subject: [PATCH] guileImportsCheckHook: init This hook should function similar to how pythonImportsCheck functions in buildPythonApplication or buildPythonPackage. Signed-off-by: Ethan Carter Edwards --- .../guileImportsCheckHook.sh | 20 +++++++++++++++++++ .../gu/guileImportsCheckHook/package.nix | 17 ++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 pkgs/by-name/gu/guileImportsCheckHook/guileImportsCheckHook.sh create mode 100644 pkgs/by-name/gu/guileImportsCheckHook/package.nix diff --git a/pkgs/by-name/gu/guileImportsCheckHook/guileImportsCheckHook.sh b/pkgs/by-name/gu/guileImportsCheckHook/guileImportsCheckHook.sh new file mode 100644 index 000000000000..9600b28e4888 --- /dev/null +++ b/pkgs/by-name/gu/guileImportsCheckHook/guileImportsCheckHook.sh @@ -0,0 +1,20 @@ +# shellcheck shell=bash + +# Setup hook for checking whether Guile imports succeed +echo "Sourcing guileImportsCheckHook.sh" + +guileImportsCheckHook () { + echo "Executing guileImportsCheckHook" + + if [[ -n "${guileImportsCheck[*]-}" ]]; then + echo "Check whether the following modules can be imported: ${guileImportsCheck[*]}" + for i in "${guileImportsCheck[@]}" + do + # prevent guile from trying to AOT compile during import + # guile can't find the library to import unless we set this + GUILE_LOAD_PATH="$out/share/guile/site/@effectiveVersion@" GUILE_AUTO_COMPILE=0 guile -c "(use-modules (${i}))" + done + fi +} + +appendToVar preDistPhases guileImportsCheckHook diff --git a/pkgs/by-name/gu/guileImportsCheckHook/package.nix b/pkgs/by-name/gu/guileImportsCheckHook/package.nix new file mode 100644 index 000000000000..7257bad1bec3 --- /dev/null +++ b/pkgs/by-name/gu/guileImportsCheckHook/package.nix @@ -0,0 +1,17 @@ +{ + lib, + makeSetupHook, + guile, + effectiveVersion ? guile.effectiveVersion, +}: + +makeSetupHook { + name = "guileImportsCheckHook"; + substitutions = { + effectiveVersion = guile.effectiveVersion; + }; + meta = { + description = "Import Guile libraries"; + maintainers = with lib.maintainers; [ ethancedwards8 ]; + }; +} ./guileImportsCheckHook.sh