1{
2 lib,
3 stdenv,
4 fetchurl,
5 racket-minimal,
6
7 cairo,
8 fontconfig,
9 glib,
10 glibcLocales,
11 gtk3,
12 libGL,
13 libiodbc,
14 libjpeg,
15 libpng,
16 makeFontsConf,
17 pango,
18 unixODBC,
19 wrapGAppsHook3,
20
21 disableDocs ? false,
22
23 callPackage,
24}:
25
26let
27 minimal = racket-minimal.override { inherit disableDocs; };
28
29 makeLibPaths = lib.concatMapStringsSep " " (
30 lib.flip lib.pipe [
31 lib.getLib
32 (x: ''"${x}/lib"'')
33 ]
34 );
35
36 manifest = lib.importJSON ./manifest.json;
37 inherit (stdenv.hostPlatform) isDarwin;
38in
39
40minimal.overrideAttrs (
41 finalAttrs: prevAttrs: {
42 src = fetchurl {
43 url = "https://mirror.racket-lang.org/installers/${manifest.version}/${manifest.full.filename}";
44 inherit (manifest.full) sha256;
45 };
46
47 buildInputs = prevAttrs.buildInputs ++ [
48 (if isDarwin then libiodbc else unixODBC)
49 cairo
50 fontconfig.lib
51 glib
52 gtk3
53 libGL
54 libjpeg
55 libpng
56 pango
57 ];
58
59 nativeBuildInputs = [
60 wrapGAppsHook3
61 ];
62
63 patches = prevAttrs.patches or [ ] ++ [
64 /*
65 Hardcode variant detection because nixpkgs wraps the Racket binary making it
66 fail to detect its variant at runtime.
67 https://github.com/NixOS/nixpkgs/issues/114993#issuecomment-812951247
68 */
69 ./patches/force-cs-variant.patch
70 ];
71
72 preBuild =
73 let
74 libPaths = makeLibPaths finalAttrs.buildInputs;
75 libPathsVar = if isDarwin then "DYLD_FALLBACK_LIBRARY_PATH" else "LD_LIBRARY_PATH";
76 in
77 /*
78 Makes FFIs available for setting up `main-distribution` and its
79 dependencies, which is integrated into the build process of Racket
80 */
81 ''
82 for lib_path in ${libPaths}; do
83 addToSearchPath ${libPathsVar} $lib_path
84 done
85 ''
86 # Fixes Fontconfig errors
87 + ''
88 export FONTCONFIG_FILE=${makeFontsConf { fontDirectories = [ ]; }}
89 export XDG_CACHE_HOME=$(mktemp -d)
90 '';
91
92 preFixup = lib.optionalString (!isDarwin) ''
93 gappsWrapperArgs+=("--set" "LOCALE_ARCHIVE" "${glibcLocales}/lib/locale/locale-archive")
94 '';
95
96 passthru =
97 let
98 notUpdated = x: !builtins.isAttrs x || lib.isDerivation x;
99 stopPred =
100 _: lhs: rhs:
101 notUpdated lhs || notUpdated rhs;
102 in
103 lib.recursiveUpdateUntil stopPred prevAttrs.passthru {
104 tests = builtins.mapAttrs (name: path: callPackage path { racket = finalAttrs.finalPackage; }) {
105 ## `main-distribution` ##
106 draw-crossing = ./tests/draw-crossing.nix;
107 };
108 };
109
110 meta = prevAttrs.meta // {
111 description = "Programmable programming language";
112 longDescription = ''
113 Racket is a full-spectrum programming language. It goes beyond
114 Lisp and Scheme with dialects that support objects, types,
115 laziness, and more. Racket enables programmers to link
116 components written in different dialects, and it empowers
117 programmers to create new, project-specific dialects. Racket's
118 libraries support applications from web servers and databases to
119 GUIs and charts.
120 '';
121 platforms = lib.platforms.unix;
122 badPlatforms = lib.platforms.darwin;
123 };
124 }
125)