Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at netboot-syslinux-multiplatform 159 lines 5.2 kB view raw
1{ lib 2, stdenv 3, fetchurl 4, fetchpatch 5, boehmgc 6, buildPackages 7, coverageAnalysis ? null 8, gawk 9, gmp 10, libffi 11, libtool 12, libunistring 13, makeWrapper 14, pkg-config 15, pkgsBuildBuild 16, readline 17, writeScript 18}: 19 20let 21 # Do either a coverage analysis build or a standard build. 22 builder = if coverageAnalysis != null 23 then coverageAnalysis 24 else stdenv.mkDerivation; 25in 26builder rec { 27 pname = "guile"; 28 version = "3.0.9"; 29 30 src = fetchurl { 31 url = "mirror://gnu/${pname}/${pname}-${version}.tar.xz"; 32 sha256 = "sha256-GiYlrHKyNm6VeS8/51j9Lfd1tARKkKSpeHMm5mwNdQ0="; 33 }; 34 35 outputs = [ "out" "dev" "info" ]; 36 setOutputFlags = false; # $dev gets into the library otherwise 37 38 depsBuildBuild = [ 39 buildPackages.stdenv.cc 40 ] ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) 41 pkgsBuildBuild.guile_3_0; 42 nativeBuildInputs = [ 43 makeWrapper 44 pkg-config 45 ]; 46 buildInputs = [ 47 libffi 48 libtool 49 libunistring 50 readline 51 ]; 52 propagatedBuildInputs = [ 53 boehmgc 54 gmp 55 56 # These ones aren't normally needed here, but `libguile*.la' has '-l' 57 # flags for them without corresponding '-L' flags. Adding them here will 58 # add the needed `-L' flags. As for why the `.la' file lacks the `-L' 59 # flags, see below. 60 libtool 61 libunistring 62 ]; 63 64 # According to 65 # https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/packages/guile.scm?h=a39207f7afd977e4e4299c6f0bb34bcb6d153818#n405 66 # starting with Guile 3.0.8, parallel builds can be done 67 # bit-reproducibly as long as we're not cross-compiling 68 enableParallelBuilding = stdenv.buildPlatform == stdenv.hostPlatform; 69 70 patches = [ 71 ./eai_system.patch 72 ] ++ lib.optional (coverageAnalysis != null) ./gcov-file-name.patch 73 ++ lib.optional stdenv.isDarwin 74 (fetchpatch { 75 url = "https://gitlab.gnome.org/GNOME/gtk-osx/raw/52898977f165777ad9ef169f7d4818f2d4c9b731/patches/guile-clocktime.patch"; 76 sha256 = "12wvwdna9j8795x59ldryv9d84c1j3qdk2iskw09306idfsis207"; 77 }); 78 79 # Explicitly link against libgcc_s, to work around the infamous 80 # "libgcc_s.so.1 must be installed for pthread_cancel to work". 81 82 # don't have "libgcc_s.so.1" on clang 83 LDFLAGS = lib.optionalString 84 (stdenv.cc.isGNU && !stdenv.hostPlatform.isStatic) "-lgcc_s"; 85 86 configureFlags = [ 87 "--with-libreadline-prefix=${lib.getDev readline}" 88 ] ++ lib.optionals stdenv.isSunOS [ 89 # Make sure the right <gmp.h> is found, and not the incompatible 90 # /usr/include/mp.h from OpenSolaris. See 91 # <https://lists.gnu.org/archive/html/hydra-users/2012-08/msg00000.html> 92 # for details. 93 "--with-libgmp-prefix=${lib.getDev gmp}" 94 95 # Same for these (?). 96 "--with-libunistring-prefix=${libunistring}" 97 98 # See below. 99 "--without-threads" 100 ] 101 # Disable JIT on Apple Silicon, as it is not yet supported 102 # https://debbugs.gnu.org/cgi/bugreport.cgi?bug=44505"; 103 ++ lib.optional (stdenv.isDarwin && stdenv.isAarch64) "--enable-jit=no" 104 # At least on x86_64-darwin '-flto' autodetection is not correct: 105 # https://github.com/NixOS/nixpkgs/pull/160051#issuecomment-1046193028 106 ++ lib.optional (stdenv.isDarwin) "--disable-lto"; 107 108 postInstall = '' 109 wrapProgram $out/bin/guile-snarf --prefix PATH : "${gawk}/bin" 110 '' 111 # XXX: See http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/18903 for 112 # why `--with-libunistring-prefix' and similar options coming from 113 # `AC_LIB_LINKFLAGS_BODY' don't work on NixOS/x86_64. 114 + '' 115 sed -i "$out/lib/pkgconfig/guile"-*.pc \ 116 -e "s|-lunistring|-L${libunistring}/lib -lunistring|g ; 117 s|^Cflags:\(.*\)$|Cflags: -I${libunistring.dev}/include \1|g ; 118 s|-lltdl|-L${libtool.lib}/lib -lltdl|g ; 119 s|includedir=$out|includedir=$dev|g 120 " 121 ''; 122 123 # make check doesn't work on darwin 124 # On Linuxes+Hydra the tests are flaky; feel free to investigate deeper. 125 doCheck = false; 126 doInstallCheck = doCheck; 127 128 setupHook = ./setup-hook-3.0.sh; 129 130 passthru = { 131 updateScript = writeScript "update-guile-3" '' 132 #!/usr/bin/env nix-shell 133 #!nix-shell -i bash -p curl pcre common-updater-scripts 134 135 set -eu -o pipefail 136 137 # Expect the text in format of '"https://ftp.gnu.org/gnu/guile/guile-3.0.8.tar.gz"' 138 new_version="$(curl -s https://www.gnu.org/software/guile/download/ | 139 pcregrep -o1 '"https://ftp.gnu.org/gnu/guile/guile-(3[.0-9]+).tar.gz"')" 140 update-source-version guile_3_0 "$new_version" 141 ''; 142 }; 143 144 meta = with lib; { 145 homepage = "https://www.gnu.org/software/guile/"; 146 description = "Embeddable Scheme implementation"; 147 longDescription = '' 148 GNU Guile is an implementation of the Scheme programming language, with 149 support for many SRFIs, packaged for use in a wide variety of 150 environments. In addition to implementing the R5RS Scheme standard and a 151 large subset of R6RS, Guile includes a module system, full access to POSIX 152 system calls, networking support, multiple threads, dynamic linking, a 153 foreign function call interface, and powerful string processing. 154 ''; 155 license = licenses.lgpl3Plus; 156 maintainers = with maintainers; [ ludo lovek323 vrthra ]; 157 platforms = platforms.all; 158 }; 159}