guileImportsCheckHook: init and convert various (#562657)

This commit is contained in:
Peder Bergebakken Sundt
2026-09-23 13:10:39 +00:00
committed by GitHub
13 changed files with 131 additions and 90 deletions

View File

@@ -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.

View File

@@ -364,6 +364,9 @@
{
"file": "hooks/gnome.section.md"
},
{
"file": "hooks/guileImportsCheckHook.section.md"
},
{
"file": "hooks/haredo.section.md"
},

View File

@@ -164,6 +164,9 @@
"ghc-deprecation-policy": [
"index.html#ghc-deprecation-policy"
],
"guileImportsCheckHook": [
"index.html#guileImportsCheckHook"
],
"how-channels-work": [
"index.html#how-channels-work"
],

View File

@@ -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";

View File

@@ -61,6 +61,10 @@ stdenv.mkDerivation (finalAttrs: {
sed -i -e '94i (test-skip 1)' ./tests/proxy.scm
'';
guileImportsCheck = [
"git"
];
__darwinAllowLocalNetworking = true;
meta = {

View File

@@ -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";

View File

@@ -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

View File

@@ -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

View File

@@ -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:
# <https://git.savannah.gnu.org/cgit/guile.git/commit/?h=branch_release-1-8&id=a0aa1e5b69d6ef0311aeea8e4b9a94eae18a1aaf>.
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;
};
}
})

View File

@@ -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;
};
}
})
//

View File

@@ -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 <bwiedemann suse de> 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;
};
}
})

View File

@@ -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";
};
}
})

View File

@@ -1,42 +0,0 @@
This patch arranges so that we don't end up, with profiling builds, with a
file named `<stdout>.gcov' since that confuses lcov:
<stdout>:cannot open source file
geninfo: ERROR: cannot read <stdout>.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 "<stdout>"
+#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 "<stdout>"
+#line 620 "c-tokenize.c"
#define INITIAL 0
@@ -799,7 +799,7 @@ YY_DECL
#line 65 "./c-tokenize.lex"
-#line 803 "<stdout>"
+#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 "<stdout>"
+#line 1239 "c-tokenize.c"
case YY_STATE_EOF(INITIAL):
yyterminate();