1 { lib, stdenv, fetchurl, makeFontsConf
3 , cairo, coreutils, fontconfig, freefont_ttf
13 , libpng, libtool, mpfr, openssl, pango, poppler
17 , gsettings-desktop-schemas
23 fontsConf = makeFontsConf {
24 fontDirectories = [ freefont_ttf ];
27 libPath = lib.makeLibraryPath ([
33 gsettings-desktop-schemas
44 ] ++ lib.optionals (!stdenv.isDarwin) [
51 stdenv.mkDerivation rec {
53 version = "8.10"; # always change at once with ./minimal.nix
55 src = (lib.makeOverridable ({ name, sha256 }:
57 url = "https://mirror.racket-lang.org/installers/${version}/${name}-src.tgz";
61 name = "${pname}-${version}";
62 sha256 = "sha256-Dklj2iwX5/bVdCi9odz2Ttp0N+Lya7bMSLR/QXo9k6M=";
65 FONTCONFIG_FILE = fontsConf;
66 LD_LIBRARY_PATH = libPath;
67 NIX_LDFLAGS = lib.concatStringsSep " " [
68 (lib.optionalString (stdenv.cc.isGNU && ! stdenv.isDarwin) "-lgcc_s")
71 nativeBuildInputs = [ cacert wrapGAppsHook ];
73 buildInputs = [ fontconfig libffi libtool sqlite gsettings-desktop-schemas gtk3 ncurses ]
74 ++ lib.optionals stdenv.isDarwin [ libiconv CoreFoundation ];
77 # Hardcode variant detection because we wrap the Racket binary making it
78 # fail to detect its variant at runtime.
79 # See: https://github.com/NixOS/nixpkgs/issues/114993#issuecomment-812951247
80 ./force-cs-variant.patch
82 # The entry point binary $out/bin/racket is codesigned at least once. The
83 # following error is triggered as a result.
84 # (error 'add-ad-hoc-signature "file already has a signature")
85 # We always remove the existing signature then call add-ad-hoc-signature to
86 # circumvent this error.
87 ./force-remove-codesign-then-add.patch
92 for f in src/lt/configure src/cs/c/configure src/bc/src/string.c; do
93 substituteInPlace "$f" \
94 --replace /usr/bin/uname ${coreutils}/bin/uname \
95 --replace /bin/cp ${coreutils}/bin/cp \
96 --replace /bin/ln ${coreutils}/bin/ln \
97 --replace /bin/rm ${coreutils}/bin/rm \
98 --replace /bin/true ${coreutils}/bin/true
101 # The configure script forces using `libtool -o` as AR on Darwin. But, the
102 # `-o` option is only available from Apple libtool. GNU ar works here.
103 substituteInPlace src/ChezScheme/zlib/configure \
104 --replace 'ARFLAGS="-o"' 'AR=ar; ARFLAGS="rc"'
109 '' + lib.optionalString stdenv.isLinux ''
110 gappsWrapperArgs+=("--prefix" "LD_LIBRARY_PATH" ":" ${libPath})
111 gappsWrapperArgs+=("--set" "LOCALE_ARCHIVE" "${glibcLocales}/lib/locale/locale-archive")
112 '' + lib.optionalString stdenv.isDarwin ''
113 gappsWrapperArgs+=("--prefix" "DYLD_LIBRARY_PATH" ":" ${libPath})
117 preBuild = lib.optionalString stdenv.isDarwin ''
118 # Cannot set DYLD_LIBRARY_PATH as an attr of this drv, becasue dynamic
119 # linker environment variables like this are purged.
120 # See: https://apple.stackexchange.com/a/212954/167199
122 # Make builders feed it to dlopen(...). Do not expose all of $libPath to
123 # DYLD_LIBRARY_PATH as the order of looking up symbols like
124 # `__cg_jpeg_resync_to_restart` will be messed up. Our libJPEG.dyllib
125 # expects it from our libTIFF.dylib, but instead it could not be found from
126 # the system `libTIFF.dylib`. DYLD_FALLBACK_LIBRARY_PATH has its own problem
128 export DYLD_FALLBACK_LIBRARY_PATH="${libPath}"
131 shared = if stdenv.isDarwin then "dylib" else "shared";
132 configureFlags = [ "--enable-${shared}" "--enable-lt=${libtool}/bin/libtool" ]
133 ++ lib.optionals disableDocs [ "--disable-docs" ]
134 ++ lib.optionals stdenv.isDarwin [ "--disable-strip" "--enable-xonx" ];
136 configureScript = "../configure";
138 enableParallelBuilding = false;
141 description = "A programmable programming language";
143 Racket is a full-spectrum programming language. It goes beyond
144 Lisp and Scheme with dialects that support objects, types,
145 laziness, and more. Racket enables programmers to link
146 components written in different dialects, and it empowers
147 programmers to create new, project-specific dialects. Racket's
148 libraries support applications from web servers and databases to
151 homepage = "https://racket-lang.org/";
152 changelog = "https://github.com/racket/racket/releases/tag/v${version}";
153 license = with licenses; [ asl20 /* or */ mit ];
154 maintainers = with maintainers; [ henrytill vrthra ];
155 platforms = [ "x86_64-darwin" "x86_64-linux" "aarch64-linux" "aarch64-darwin" ];