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 makeWrapper,
15 pkg-config,
16 pkgsBuildBuild,
17 readline,
18}:
19
20let
21 # Do either a coverage analysis build or a standard build.
22 builder = if coverageAnalysis != null then coverageAnalysis else stdenv.mkDerivation;
23in
24builder rec {
25 pname = "guile";
26 version = "2.2.7";
27
28 src = fetchurl {
29 url = "mirror://gnu/${pname}/${pname}-${version}.tar.xz";
30 sha256 = "013mydzhfswqci6xmyc1ajzd59pfbdak15i0b090nhr9bzm7dxyd";
31 };
32
33 outputs = [
34 "out"
35 "dev"
36 "info"
37 ];
38 setOutputFlags = false; # $dev gets into the library otherwise
39
40 depsBuildBuild = [
41 buildPackages.stdenv.cc
42 ]
43 ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) pkgsBuildBuild.guile_2_2;
44 nativeBuildInputs = [
45 makeWrapper
46 pkg-config
47 ];
48 buildInputs = [
49 libffi
50 libtool
51 libunistring
52 readline
53 ];
54 propagatedBuildInputs = [
55 boehmgc
56 gmp
57
58 # XXX: These ones aren't normally needed here, but `libguile*.la' has '-l'
59 # flags for them without corresponding '-L' flags. Adding them here will add
60 # the needed `-L' flags. As for why the `.la' file lacks the `-L' flags,
61 # see below.
62 libtool
63 libunistring
64 ];
65
66 # According to Bernhard M. Wiedemann <bwiedemann suse de> on
67 # #reproducible-builds on irc.oftc.net, (2020-01-29): they had to
68 # build Guile without parallel builds to make it reproducible.
69 #
70 # re: https://issues.guix.gnu.org/issue/20272
71 # re: https://build.opensuse.org/request/show/732638
72 enableParallelBuilding = false;
73
74 patches = [
75 # Read the header of the patch to more info
76 ./eai_system.patch
77 ]
78 ++ lib.optional (coverageAnalysis != null) ./gcov-file-name.patch
79 ++ lib.optional stdenv.hostPlatform.isDarwin (fetchpatch {
80 url = "https://gitlab.gnome.org/GNOME/gtk-osx/raw/52898977f165777ad9ef169f7d4818f2d4c9b731/patches/guile-clocktime.patch";
81 sha256 = "12wvwdna9j8795x59ldryv9d84c1j3qdk2iskw09306idfsis207";
82 });
83
84 # Explicitly link against libgcc_s, to work around the infamous
85 # "libgcc_s.so.1 must be installed for pthread_cancel to work".
86
87 # don't have "libgcc_s.so.1" on clang
88 env = lib.optionalAttrs (stdenv.cc.isGNU && !stdenv.hostPlatform.isStatic) {
89 LDFLAGS = "-lgcc_s";
90 };
91
92 configureFlags = [
93 "--with-libreadline-prefix=${lib.getDev readline}"
94 ]
95 ++ lib.optionals stdenv.hostPlatform.isSunOS [
96 # Make sure the right <gmp.h> is found, and not the incompatible
97 # /usr/include/mp.h from OpenSolaris. See
98 # <https://lists.gnu.org/archive/html/hydra-users/2012-08/msg00000.html>
99 # for details.
100 "--with-libgmp-prefix=${lib.getDev gmp}"
101
102 # Same for these (?).
103 "--with-libunistring-prefix=${libunistring}"
104
105 # See below.
106 "--without-threads"
107 ];
108
109 postInstall = ''
110 wrapProgram $out/bin/guile-snarf --prefix PATH : "${gawk}/bin"
111 ''
112 # XXX: See http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/18903 for
113 # why `--with-libunistring-prefix' and similar options coming from
114 # `AC_LIB_LINKFLAGS_BODY' don't work on NixOS/x86_64.
115 + ''
116 sed -i "$out/lib/pkgconfig/guile"-*.pc \
117 -e "s|-lunistring|-L${libunistring}/lib -lunistring|g ;
118 s|^Cflags:\(.*\)$|Cflags: -I${libunistring.dev}/include \1|g ;
119 s|-lltdl|-L${libtool.lib}/lib -lltdl|g ;
120 s|includedir=$out|includedir=$dev|g
121 "
122 '';
123
124 # make check doesn't work on darwin
125 # On Linuxes+Hydra the tests are flaky; feel free to investigate deeper.
126 doCheck = false;
127 doInstallCheck = doCheck;
128
129 setupHook = ./setup-hook-2.2.sh;
130
131 passthru = rec {
132 effectiveVersion = lib.versions.majorMinor version;
133 siteCcacheDir = "lib/guile/${effectiveVersion}/site-ccache";
134 siteDir = "share/guile/site/${effectiveVersion}";
135 };
136
137 meta = {
138 homepage = "https://www.gnu.org/software/guile/";
139 description = "Embeddable Scheme implementation";
140 longDescription = ''
141 GNU Guile is an implementation of the Scheme programming language, with
142 support for many SRFIs, packaged for use in a wide variety of
143 environments. In addition to implementing the R5RS Scheme standard and a
144 large subset of R6RS, Guile includes a module system, full access to POSIX
145 system calls, networking support, multiple threads, dynamic linking, a
146 foreign function call interface, and powerful string processing.
147 '';
148 license = lib.licenses.lgpl3Plus;
149 maintainers = with lib.maintainers; [ ludo ];
150 platforms = lib.platforms.all;
151 };
152}