From abecc6115041edef84d90b9ed600a853cfe8ddea Mon Sep 17 00:00:00 2001 From: Ethan Carter Edwards Date: Sun, 8 Jun 2025 18:37:55 -0400 Subject: [PATCH 1/6] 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 From aa633dff01ea307699a3be2d53d6c7cf99cc30f5 Mon Sep 17 00:00:00 2001 From: Ethan Carter Edwards Date: Sun, 13 Sep 2026 20:46:45 -0400 Subject: [PATCH 2/6] guile*: cleanup, propagate guileImportsCheckHook Removing coverageAnalysis was discussed on Matrix with xokdvium. It isn't used anymore. Signed-off-by: Ethan Carter Edwards --- pkgs/development/interpreters/guile/1.8.nix | 14 ++++--- pkgs/development/interpreters/guile/2.0.nix | 26 ++++++------ pkgs/development/interpreters/guile/2.2.nix | 25 ++++++----- pkgs/development/interpreters/guile/3.0.nix | 28 ++++++------- .../interpreters/guile/gcov-file-name.patch | 42 ------------------- 5 files changed, 46 insertions(+), 89 deletions(-) delete mode 100644 pkgs/development/interpreters/guile/gcov-file-name.patch diff --git a/pkgs/development/interpreters/guile/1.8.nix b/pkgs/development/interpreters/guile/1.8.nix index 3bc734fd12fc..939c17af21ad 100644 --- a/pkgs/development/interpreters/guile/1.8.nix +++ b/pkgs/development/interpreters/guile/1.8.nix @@ -10,14 +10,15 @@ pkg-config, pkgsBuildBuild, readline, + guileImportsCheckHook, }: -stdenv.mkDerivation rec { +stdenv.mkDerivation (finalAttrs: { pname = "guile"; version = "1.8.8"; src = fetchurl { - url = "mirror://gnu/${pname}/${pname}-${version}.tar.gz"; + url = "mirror://gnu/guile/guile-${finalAttrs.version}.tar.gz"; sha256 = "0l200a0v7h8bh0cwz6v7hc13ds39cgqsmfrks55b1rbj5vniyiy3"; }; @@ -57,6 +58,9 @@ stdenv.mkDerivation rec { # see below. libtool ]; + propagatedNativeBuildInputs = lib.optionals (stdenv.buildPlatform == stdenv.hostPlatform) [ + (guileImportsCheckHook.override { effectiveVersion = finalAttrs.passthru.effectiveVersion; }) + ]; patches = [ # Fix doc snarfing with GCC 4.5. @@ -89,12 +93,12 @@ stdenv.mkDerivation rec { # This is fixed here: # . doCheck = false; - doInstallCheck = doCheck; + doInstallCheck = finalAttrs.doCheck; setupHook = ./setup-hook-1.8.sh; passthru = { - effectiveVersion = lib.versions.majorMinor version; + effectiveVersion = lib.versions.majorMinor finalAttrs.version; siteCcacheDir = "lib/guile/site-ccache"; siteDir = "share/guile/site"; }; @@ -114,4 +118,4 @@ stdenv.mkDerivation rec { maintainers = with lib.maintainers; [ ludo ]; platforms = lib.platforms.all; }; -} +}) diff --git a/pkgs/development/interpreters/guile/2.0.nix b/pkgs/development/interpreters/guile/2.0.nix index 9d207f70c0c7..0110357541fc 100644 --- a/pkgs/development/interpreters/guile/2.0.nix +++ b/pkgs/development/interpreters/guile/2.0.nix @@ -5,7 +5,6 @@ fetchpatch, boehmgc, buildPackages, - coverageAnalysis ? null, gawk, gmp, libffi, @@ -15,18 +14,15 @@ pkg-config, pkgsBuildBuild, readline, + guileImportsCheckHook, }: -let - # Do either a coverage analysis build or a standard build. - builder = if coverageAnalysis != null then coverageAnalysis else stdenv.mkDerivation; -in -builder rec { +stdenv.mkDerivation (finalAttrs: { pname = "guile"; version = "2.0.13"; src = fetchurl { - url = "mirror://gnu/${pname}/${pname}-${version}.tar.xz"; + url = "mirror://gnu/guile/guile-${finalAttrs.version}.tar.xz"; sha256 = "12yqkr974y91ylgw6jnmci2v90i90s7h9vxa4zk0sai8vjnz4i1p"; }; @@ -63,6 +59,9 @@ builder rec { libtool libunistring ]; + propagatedNativeBuildInputs = lib.optionals (stdenv.buildPlatform == stdenv.hostPlatform) [ + (guileImportsCheckHook.override { effectiveVersion = finalAttrs.passthru.effectiveVersion; }) + ]; enableParallelBuilding = true; @@ -81,7 +80,6 @@ builder rec { sha256 = "0p6c1lmw1iniq03z7x5m65kg3lq543kgvdb4nrxsaxjqf3zhl77v"; }) ] - ++ (lib.optional (coverageAnalysis != null) ./gcov-file-name.patch) ++ lib.optionals stdenv.hostPlatform.isDarwin [ ./filter-mkostemp-darwin.patch (fetchpatch { @@ -136,14 +134,14 @@ builder rec { # make check doesn't work on darwin # On Linuxes+Hydra the tests are flaky; feel free to investigate deeper. doCheck = false; - doInstallCheck = doCheck; + doInstallCheck = finalAttrs.doCheck; setupHook = ./setup-hook-2.0.sh; - passthru = rec { - effectiveVersion = lib.versions.majorMinor version; - siteCcacheDir = "lib/guile/${effectiveVersion}/site-ccache"; - siteDir = "share/guile/site/${effectiveVersion}"; + passthru = { + effectiveVersion = lib.versions.majorMinor finalAttrs.version; + siteCcacheDir = "lib/guile/${finalAttrs.passthru.effectiveVersion}/site-ccache"; + siteDir = "share/guile/site/${finalAttrs.passthru.effectiveVersion}"; }; meta = { @@ -162,7 +160,7 @@ builder rec { maintainers = with lib.maintainers; [ ludo ]; platforms = lib.platforms.all; }; -} +}) // diff --git a/pkgs/development/interpreters/guile/2.2.nix b/pkgs/development/interpreters/guile/2.2.nix index c48fa78594bd..140ea705f865 100644 --- a/pkgs/development/interpreters/guile/2.2.nix +++ b/pkgs/development/interpreters/guile/2.2.nix @@ -15,18 +15,15 @@ pkg-config, pkgsBuildBuild, readline, + guileImportsCheckHook, }: -let - # Do either a coverage analysis build or a standard build. - builder = if coverageAnalysis != null then coverageAnalysis else stdenv.mkDerivation; -in -builder rec { +stdenv.mkDerivation (finalAttrs: { pname = "guile"; version = "2.2.7"; src = fetchurl { - url = "mirror://gnu/${pname}/${pname}-${version}.tar.xz"; + url = "mirror://gnu/guile/guile-${finalAttrs.version}.tar.xz"; sha256 = "013mydzhfswqci6xmyc1ajzd59pfbdak15i0b090nhr9bzm7dxyd"; }; @@ -62,6 +59,9 @@ builder rec { libtool libunistring ]; + propagatedNativeBuildInputs = lib.optionals (stdenv.buildPlatform == stdenv.hostPlatform) [ + (guileImportsCheckHook.override { effectiveVersion = finalAttrs.passthru.effectiveVersion; }) + ]; # According to Bernhard M. Wiedemann on # #reproducible-builds on irc.oftc.net, (2020-01-29): they had to @@ -75,7 +75,6 @@ builder rec { # Read the header of the patch to more info ./eai_system.patch ] - ++ lib.optional (coverageAnalysis != null) ./gcov-file-name.patch ++ lib.optional stdenv.hostPlatform.isDarwin (fetchpatch { url = "https://gitlab.gnome.org/GNOME/gtk-osx/raw/52898977f165777ad9ef169f7d4818f2d4c9b731/patches/guile-clocktime.patch"; sha256 = "12wvwdna9j8795x59ldryv9d84c1j3qdk2iskw09306idfsis207"; @@ -124,14 +123,14 @@ builder rec { # make check doesn't work on darwin # On Linuxes+Hydra the tests are flaky; feel free to investigate deeper. doCheck = false; - doInstallCheck = doCheck; + doInstallCheck = finalAttrs.doCheck; setupHook = ./setup-hook-2.2.sh; - passthru = rec { - effectiveVersion = lib.versions.majorMinor version; - siteCcacheDir = "lib/guile/${effectiveVersion}/site-ccache"; - siteDir = "share/guile/site/${effectiveVersion}"; + passthru = { + effectiveVersion = lib.versions.majorMinor finalAttrs.version; + siteCcacheDir = "lib/guile/${finalAttrs.passthru.effectiveVersion}/site-ccache"; + siteDir = "share/guile/site/${finalAttrs.passthru.effectiveVersion}"; }; meta = { @@ -149,4 +148,4 @@ builder rec { maintainers = with lib.maintainers; [ ludo ]; platforms = lib.platforms.all; }; -} +}) diff --git a/pkgs/development/interpreters/guile/3.0.nix b/pkgs/development/interpreters/guile/3.0.nix index 8093ec393ec4..8cee8bcec4a7 100644 --- a/pkgs/development/interpreters/guile/3.0.nix +++ b/pkgs/development/interpreters/guile/3.0.nix @@ -5,7 +5,6 @@ fetchpatch, boehmgc, buildPackages, - coverageAnalysis ? null, gawk, gmp, libffi, @@ -19,19 +18,16 @@ readline, writeScript, pkgsStatic, + guileImportsCheckHook, }: -let - # Do either a coverage analysis build or a standard build. - builder = if coverageAnalysis != null then coverageAnalysis else stdenv.mkDerivation; -in -builder rec { +stdenv.mkDerivation (finalAttrs: { pname = "guile"; version = "3.0.11"; src = fetchurl { - url = "mirror://gnu/${pname}/${pname}-${version}.tar.xz"; - sha256 = "sha256-gYx50jZlen+pb7NkE3zHtBs73uDWXGF0ygN2lVlXlGA="; + url = "mirror://gnu/guile/guile-${finalAttrs.version}.tar.xz"; + hash = "sha256-gYx50jZlen+pb7NkE3zHtBs73uDWXGF0ygN2lVlXlGA="; }; outputs = [ @@ -77,6 +73,9 @@ builder rec { ++ lib.optionals stdenv.hostPlatform.isLinux [ libxcrypt ]; + propagatedNativeBuildInputs = lib.optionals (stdenv.buildPlatform == stdenv.hostPlatform) [ + (guileImportsCheckHook.override { effectiveVersion = finalAttrs.passthru.effectiveVersion; }) + ]; strictDeps = true; @@ -89,7 +88,6 @@ builder rec { patches = [ ./eai_system.patch ] - ++ lib.optional (coverageAnalysis != null) ./gcov-file-name.patch ++ lib.optional stdenv.hostPlatform.isDarwin (fetchpatch { url = "https://gitlab.gnome.org/GNOME/gtk-osx/raw/52898977f165777ad9ef169f7d4818f2d4c9b731/patches/guile-clocktime.patch"; sha256 = "12wvwdna9j8795x59ldryv9d84c1j3qdk2iskw09306idfsis207"; @@ -145,7 +143,7 @@ builder rec { # make check doesn't work on darwin # On Linuxes+Hydra the tests are flaky; feel free to investigate deeper. doCheck = false; - doInstallCheck = doCheck; + doInstallCheck = finalAttrs.doCheck; # guile-3 uses ELF files to store bytecode. strip does not # always handle them correctly and destroys the image: @@ -156,12 +154,12 @@ builder rec { setupHook = ./setup-hook-3.0.sh; - passthru = rec { + passthru = { tests.static = pkgsStatic.guile; - effectiveVersion = lib.versions.majorMinor version; - siteCcacheDir = "lib/guile/${effectiveVersion}/site-ccache"; - siteDir = "share/guile/site/${effectiveVersion}"; + effectiveVersion = lib.versions.majorMinor finalAttrs.version; + siteCcacheDir = "lib/guile/${finalAttrs.passthru.effectiveVersion}/site-ccache"; + siteDir = "share/guile/site/${finalAttrs.passthru.effectiveVersion}"; updateScript = writeScript "update-guile-3" '' #!/usr/bin/env nix-shell @@ -193,4 +191,4 @@ builder rec { platforms = lib.platforms.all; mainProgram = "guile"; }; -} +}) diff --git a/pkgs/development/interpreters/guile/gcov-file-name.patch b/pkgs/development/interpreters/guile/gcov-file-name.patch deleted file mode 100644 index f144296170ed..000000000000 --- a/pkgs/development/interpreters/guile/gcov-file-name.patch +++ /dev/null @@ -1,42 +0,0 @@ -This patch arranges so that we don't end up, with profiling builds, with a -file named `.gcov' since that confuses lcov: - - :cannot open source file - geninfo: ERROR: cannot read .gcov! - ---- guile/libguile/c-tokenize.c 2009-09-13 13:05:15.000000000 +0200 -+++ guile/libguile/c-tokenize.c 2009-10-28 16:24:15.000000000 +0100 -@@ -1,5 +1,5 @@ - --#line 3 "" -+#line 3 "c-tokenize.c" - - #define YY_INT_ALIGNED short int - -@@ -616,7 +616,7 @@ int cookie_was_last = 0; - #define IS_COOKIE cookie_was_last = 1 - #define IS_NOT_COOKIE cookie_was_last = 0 - --#line 620 "" -+#line 620 "c-tokenize.c" - - #define INITIAL 0 - -@@ -799,7 +799,7 @@ YY_DECL - #line 65 "./c-tokenize.lex" - - --#line 803 "" -+#line 803 "c-tokenize.c" - - if ( !(yy_init) ) - { -@@ -1235,7 +1235,7 @@ YY_RULE_SETUP - #line 181 "./c-tokenize.lex" - ECHO; - YY_BREAK --#line 1239 "" -+#line 1239 "c-tokenize.c" - case YY_STATE_EOF(INITIAL): - yyterminate(); - From e80f238f98e697e12fc709ed708d0473990efdcc Mon Sep 17 00:00:00 2001 From: Ethan Carter Edwards Date: Sat, 12 Sep 2026 12:56:37 -0400 Subject: [PATCH 3/6] guile-git: use guileImportsCheckHook Signed-off-by: Ethan Carter Edwards --- pkgs/by-name/gu/guile-git/package.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/by-name/gu/guile-git/package.nix b/pkgs/by-name/gu/guile-git/package.nix index 839cf537629e..203da06d5934 100644 --- a/pkgs/by-name/gu/guile-git/package.nix +++ b/pkgs/by-name/gu/guile-git/package.nix @@ -61,6 +61,10 @@ stdenv.mkDerivation (finalAttrs: { sed -i -e '94i (test-skip 1)' ./tests/proxy.scm ''; + guileImportsCheck = [ + "git" + ]; + __darwinAllowLocalNetworking = true; meta = { From b1436e063434474d2fb7fc01861c29b3a5c1beb5 Mon Sep 17 00:00:00 2001 From: Ethan Carter Edwards Date: Sat, 12 Sep 2026 13:04:00 -0400 Subject: [PATCH 4/6] guile-json: use guileImportsCheckHook Converted to a structuredAttrs consumer Signed-off-by: Ethan Carter Edwards --- pkgs/by-name/gu/guile-json/package.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkgs/by-name/gu/guile-json/package.nix b/pkgs/by-name/gu/guile-json/package.nix index 2cc2a8d572ad..ba3849e3c356 100644 --- a/pkgs/by-name/gu/guile-json/package.nix +++ b/pkgs/by-name/gu/guile-json/package.nix @@ -13,9 +13,10 @@ stdenv.mkDerivation (finalAttrs: { src = fetchurl { url = "mirror://savannah/guile-json/guile-json-${finalAttrs.version}.tar.gz"; - sha256 = "sha256-OLoEjtKdEvBbMsWy+3pReVxEi0HkA6Kxty/wA1gX84g="; + hash = "sha256-OLoEjtKdEvBbMsWy+3pReVxEi0HkA6Kxty/wA1gX84g="; }; + __structuredAttrs = true; strictDeps = true; nativeBuildInputs = [ guile @@ -28,6 +29,10 @@ stdenv.mkDerivation (finalAttrs: { doCheck = true; makeFlags = [ "GUILE_AUTO_COMPILE=0" ]; + guileImportsCheck = [ + "json" + ]; + meta = { description = "JSON Bindings for GNU Guile"; homepage = "https://savannah.nongnu.org/projects/guile-json"; From 419deb3220c8b643ee561c9989644854b9cfb0a1 Mon Sep 17 00:00:00 2001 From: Ethan Carter Edwards Date: Sat, 12 Sep 2026 13:23:27 -0400 Subject: [PATCH 5/6] guile-commonmark: use guileImportsCheckHook Signed-off-by: Ethan Carter Edwards --- pkgs/by-name/gu/guile-commonmark/package.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/by-name/gu/guile-commonmark/package.nix b/pkgs/by-name/gu/guile-commonmark/package.nix index 3b7772efdc66..5674f5ab9841 100644 --- a/pkgs/by-name/gu/guile-commonmark/package.nix +++ b/pkgs/by-name/gu/guile-commonmark/package.nix @@ -39,6 +39,10 @@ stdenv.mkDerivation { "GUILE_AUTO_COMPILE=0" ]; + guileImportsCheck = [ + "commonmark" + ]; + meta = { homepage = "https://github.com/OrangeShark/guile-commonmark"; description = "Implementation of CommonMark for Guile"; From 3564c9c95b13eb742c4378d47ed219cc530d0249 Mon Sep 17 00:00:00 2001 From: Ethan Carter Edwards Date: Sun, 13 Sep 2026 17:53:06 -0400 Subject: [PATCH 6/6] doc/guileImportsCheckHook: init hook docs in manual Signed-off-by: Ethan Carter Edwards --- doc/hooks/guileImportsCheckHook.section.md | 28 ++++++++++++++++++++++ doc/nav.json | 3 +++ doc/redirects.json | 3 +++ 3 files changed, 34 insertions(+) create mode 100644 doc/hooks/guileImportsCheckHook.section.md diff --git a/doc/hooks/guileImportsCheckHook.section.md b/doc/hooks/guileImportsCheckHook.section.md new file mode 100644 index 000000000000..5e476df4c63f --- /dev/null +++ b/doc/hooks/guileImportsCheckHook.section.md @@ -0,0 +1,28 @@ +# `guileImportsCheckHook` {#guileImportsCheckHook} + +This hook checks if a guile package can be imported. The hook is automatically +propagated by `guile`, so using it is as simple as: + +```nix +{ + lib, + stdenv, + guile, + # ... +}: + +stdenv.mkDerivation (finalAttrs: { + # ... + + nativeBuildInputs = [ guile ]; + + guileImportsCheck = [ + "package" + ]; + + # ... +}) +``` + +The `guileImportsCheckHook` package can also included manually in +`nativeBuildInputs` if one desires. diff --git a/doc/nav.json b/doc/nav.json index cc361e87593f..56c6c4492a07 100644 --- a/doc/nav.json +++ b/doc/nav.json @@ -364,6 +364,9 @@ { "file": "hooks/gnome.section.md" }, + { + "file": "hooks/guileImportsCheckHook.section.md" + }, { "file": "hooks/haredo.section.md" }, diff --git a/doc/redirects.json b/doc/redirects.json index c247c05dcd9b..6a926a0a978f 100644 --- a/doc/redirects.json +++ b/doc/redirects.json @@ -164,6 +164,9 @@ "ghc-deprecation-policy": [ "index.html#ghc-deprecation-policy" ], + "guileImportsCheckHook": [ + "index.html#guileImportsCheckHook" + ], "how-channels-work": [ "index.html#how-channels-work" ],