nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchurl,
5 fetchpatch,
6 boehmgc,
7 buildPackages,
8 coverageAnalysis ? null,
9 gawk,
10 gmp,
11 libffi,
12 libtool,
13 libunistring,
14 libxcrypt,
15 makeWrapper,
16 pkg-config,
17 autoreconfHook,
18 pkgsBuildBuild,
19 readline,
20 writeScript,
21}:
22
23let
24 # Do either a coverage analysis build or a standard build.
25 builder = if coverageAnalysis != null then coverageAnalysis else stdenv.mkDerivation;
26in
27builder rec {
28 pname = "guile";
29 version = "3.0.11";
30
31 src = fetchurl {
32 url = "mirror://gnu/${pname}/${pname}-${version}.tar.xz";
33 sha256 = "sha256-gYx50jZlen+pb7NkE3zHtBs73uDWXGF0ygN2lVlXlGA=";
34 };
35
36 outputs = [
37 "out"
38 "dev"
39 "info"
40 ];
41 setOutputFlags = false; # $dev gets into the library otherwise
42
43 depsBuildBuild = [
44 buildPackages.stdenv.cc
45 ]
46 ++ lib.optional (
47 !lib.systems.equals stdenv.hostPlatform stdenv.buildPlatform
48 ) pkgsBuildBuild.guile_3_0;
49
50 nativeBuildInputs = [
51 makeWrapper
52 pkg-config
53 ]
54 ++ lib.optional (!lib.systems.equals stdenv.hostPlatform stdenv.buildPlatform) autoreconfHook;
55
56 buildInputs = [
57 libffi
58 libtool
59 libunistring
60 readline
61 ]
62 ++ lib.optionals stdenv.hostPlatform.isLinux [
63 libxcrypt
64 ];
65 propagatedBuildInputs = [
66 boehmgc
67 gmp
68
69 # These ones aren't normally needed here, but `libguile*.la' has '-l'
70 # flags for them without corresponding '-L' flags. Adding them here will
71 # add the needed `-L' flags. As for why the `.la' file lacks the `-L'
72 # flags, see below.
73 libtool
74 libunistring
75 ]
76 ++ lib.optionals stdenv.hostPlatform.isLinux [
77 libxcrypt
78 ];
79
80 strictDeps = true;
81
82 # According to
83 # https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/packages/guile.scm?h=a39207f7afd977e4e4299c6f0bb34bcb6d153818#n405
84 # starting with Guile 3.0.8, parallel builds can be done
85 # bit-reproducibly as long as we're not cross-compiling
86 enableParallelBuilding = lib.systems.equals stdenv.buildPlatform stdenv.hostPlatform;
87
88 patches = [
89 ./eai_system.patch
90 ]
91 # Fix cross-compilation, can be removed at next release (as well as the autoreconfHook)
92 # Include this only conditionally so we don't have to run the autoreconfHook for the native build.
93 ++ lib.optional (!lib.systems.equals stdenv.hostPlatform stdenv.buildPlatform) (fetchpatch {
94 url = "https://cgit.git.savannah.gnu.org/cgit/guile.git/patch/?id=c117f8edc471d3362043d88959d73c6a37e7e1e9";
95 hash = "sha256-GFwJiwuU8lT1fNueMOcvHh8yvA4HYHcmPml2fY/HSjw=";
96 })
97 ++ lib.optional (coverageAnalysis != null) ./gcov-file-name.patch
98 ++ lib.optional stdenv.hostPlatform.isDarwin (fetchpatch {
99 url = "https://gitlab.gnome.org/GNOME/gtk-osx/raw/52898977f165777ad9ef169f7d4818f2d4c9b731/patches/guile-clocktime.patch";
100 sha256 = "12wvwdna9j8795x59ldryv9d84c1j3qdk2iskw09306idfsis207";
101 });
102
103 env = {
104 # Fix build with gcc15
105 NIX_CFLAGS_COMPILE = toString [ "-std=gnu17" ];
106 }
107 // lib.optionalAttrs (stdenv.cc.isGNU && !stdenv.hostPlatform.isStatic) {
108 # Explicitly link against libgcc_s, to work around the infamous
109 # "libgcc_s.so.1 must be installed for pthread_cancel to work".
110 # don't have "libgcc_s.so.1" on clang
111 LDFLAGS = "-lgcc_s";
112 };
113
114 configureFlags = [
115 "--with-libreadline-prefix=${lib.getDev readline}"
116 ]
117 ++ lib.optionals stdenv.hostPlatform.isSunOS [
118 # Make sure the right <gmp.h> is found, and not the incompatible
119 # /usr/include/mp.h from OpenSolaris. See
120 # <https://lists.gnu.org/archive/html/hydra-users/2012-08/msg00000.html>
121 # for details.
122 "--with-libgmp-prefix=${lib.getDev gmp}"
123
124 # Same for these (?).
125 "--with-libunistring-prefix=${libunistring}"
126
127 # See below.
128 "--without-threads"
129 ]
130 # At least on x86_64-darwin '-flto' autodetection is not correct:
131 # https://github.com/NixOS/nixpkgs/pull/160051#issuecomment-1046193028
132 ++ lib.optional (stdenv.hostPlatform.isDarwin) "--disable-lto";
133
134 postInstall = ''
135 wrapProgram $out/bin/guile-snarf --prefix PATH : "${gawk}/bin"
136 ''
137 # XXX: See http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/18903 for
138 # why `--with-libunistring-prefix' and similar options coming from
139 # `AC_LIB_LINKFLAGS_BODY' don't work on NixOS/x86_64.
140 + ''
141 sed -i "$out/lib/pkgconfig/guile"-*.pc \
142 -e "s|-lunistring|-L${libunistring}/lib -lunistring|g ;
143 s|-lltdl|-L${libtool.lib}/lib -lltdl|g ;
144 s|-lcrypt|-L${libxcrypt}/lib -lcrypt|g ;
145 s|^Cflags:\(.*\)$|Cflags: -I${libunistring.dev}/include \1|g ;
146 s|includedir=$out|includedir=$dev|g
147 "
148 '';
149
150 # make check doesn't work on darwin
151 # On Linuxes+Hydra the tests are flaky; feel free to investigate deeper.
152 doCheck = false;
153 doInstallCheck = doCheck;
154
155 # guile-3 uses ELF files to store bytecode. strip does not
156 # always handle them correctly and destroys the image:
157 # darwin: In procedure bytevector-u8-ref: Argument 2 out of range
158 # linux binutils-2.45: $ guile --version
159 # Pre-boot error; key: misc-error, args: ("load-thunk-from-memory" "missing DT_GUILE_ENTRY" () #f)Aborted
160 dontStrip = true;
161
162 setupHook = ./setup-hook-3.0.sh;
163
164 passthru = rec {
165 effectiveVersion = lib.versions.majorMinor version;
166 siteCcacheDir = "lib/guile/${effectiveVersion}/site-ccache";
167 siteDir = "share/guile/site/${effectiveVersion}";
168
169 updateScript = writeScript "update-guile-3" ''
170 #!/usr/bin/env nix-shell
171 #!nix-shell -i bash -p curl pcre common-updater-scripts
172
173 set -eu -o pipefail
174
175 # Expect the text in format of '"https://ftp.gnu.org/gnu/guile/guile-3.0.8.tar.gz"'
176 new_version="$(curl -s https://www.gnu.org/software/guile/download/ |
177 pcregrep -o1 '"https://ftp.gnu.org/gnu/guile/guile-(3[.0-9]+).tar.gz"')"
178 update-source-version guile_3_0 "$new_version"
179 '';
180 };
181
182 meta = {
183 homepage = "https://www.gnu.org/software/guile/";
184 description = "Embeddable Scheme implementation";
185 longDescription = ''
186 GNU Guile is an implementation of the Scheme programming language, with
187 support for many SRFIs, packaged for use in a wide variety of
188 environments. In addition to implementing the R5RS Scheme standard and a
189 large subset of R6RS, Guile includes a module system, full access to POSIX
190 system calls, networking support, multiple threads, dynamic linking, a
191 foreign function call interface, and powerful string processing.
192 '';
193 license = lib.licenses.lgpl3Plus;
194 maintainers = [ ];
195 platforms = lib.platforms.all;
196 };
197}