nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
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 manifest = lib.importJSON ./manifest.json;
30 inherit (stdenv.hostPlatform) isDarwin;
31in
32
33minimal.overrideAttrs (
34 finalAttrs: prevAttrs: {
35 src = fetchurl {
36 url = "https://mirror.racket-lang.org/installers/${manifest.version}/${manifest.full.filename}";
37 inherit (manifest.full) sha256;
38 };
39
40 buildInputs = prevAttrs.buildInputs ++ [
41 (if isDarwin then libiodbc else unixODBC)
42 cairo
43 fontconfig.lib
44 glib
45 gtk3
46 libGL
47 libjpeg
48 libpng
49 pango
50 ];
51
52 nativeBuildInputs = [
53 wrapGAppsHook3
54 ];
55
56 patches = prevAttrs.patches or [ ] ++ [
57 /*
58 Hardcode variant detection because nixpkgs wraps the Racket binary making it
59 fail to detect its variant at runtime.
60 https://github.com/NixOS/nixpkgs/issues/114993#issuecomment-812951247
61 */
62 ./patches/force-cs-variant.patch
63 ];
64
65 preBuild =
66 let
67 libPathsVar = if isDarwin then "DYLD_FALLBACK_LIBRARY_PATH" else "LD_LIBRARY_PATH";
68 in
69 /*
70 Makes FFIs available for setting up `main-distribution` and its
71 dependencies, which is integrated into the build process of Racket
72 */
73 ''
74 for lib_path in $( \
75 echo "$NIX_LDFLAGS" \
76 | tr ' ' '\n' \
77 | grep '^-L' \
78 | sed 's/^-L//' \
79 | awk '!seen[$0]++' \
80 ); do
81 addToSearchPath ${libPathsVar} $lib_path
82 done
83 ''
84 # Fixes Fontconfig errors
85 + ''
86 export FONTCONFIG_FILE=${makeFontsConf { fontDirectories = [ ]; }}
87 export XDG_CACHE_HOME=$(mktemp -d)
88 '';
89
90 dontWrapGApps = true;
91
92 preFixup = lib.optionalString (!isDarwin) ''
93 gappsWrapperArgs+=("--set" "LOCALE_ARCHIVE" "${glibcLocales}/lib/locale/locale-archive")
94
95 find $out/bin -type f -executable -print0 |
96 while IFS= read -r -d ''' f; do
97 if test "$(file --brief --mime-type "$f")" = application/x-executable; then
98 wrapGApp "$f"
99 fi
100 done
101
102 wrapGApp $out/lib/racket/gracket
103 '';
104
105 passthru =
106 let
107 notUpdated = x: !builtins.isAttrs x || lib.isDerivation x;
108 stopPred =
109 _: lhs: rhs:
110 notUpdated lhs || notUpdated rhs;
111 in
112 lib.recursiveUpdateUntil stopPred prevAttrs.passthru {
113 tests = builtins.mapAttrs (name: path: callPackage path { racket = finalAttrs.finalPackage; }) {
114 ## `main-distribution` ##
115 draw-crossing = ./tests/draw-crossing.nix;
116 };
117 };
118
119 meta = prevAttrs.meta // {
120 description = "Programmable programming language";
121 longDescription = ''
122 Racket is a full-spectrum programming language. It goes beyond
123 Lisp and Scheme with dialects that support objects, types,
124 laziness, and more. Racket enables programmers to link
125 components written in different dialects, and it empowers
126 programmers to create new, project-specific dialects. Racket's
127 libraries support applications from web servers and databases to
128 GUIs and charts.
129 '';
130 platforms = lib.platforms.unix;
131 badPlatforms = lib.platforms.darwin;
132 };
133 }
134)