nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 config,
3 stdenv,
4 lib,
5 fetchFromGitHub,
6 fetchurl,
7 alsa-lib,
8 coreutils,
9 file,
10 freetype,
11 gnugrep,
12 libpulseaudio,
13 libtool,
14 libuuid,
15 openssl,
16 pango,
17 pkg-config,
18 libxrandr,
19 libx11,
20}:
21let
22 buildVM =
23 {
24 # VM-specific information, manually extracted from building/<platformDir>/<vmName>/build/mvm
25 platformDir,
26 vmName,
27 scriptName,
28 configureFlagsArray,
29 configureFlags,
30 }:
31 let
32 src = fetchFromGitHub {
33 owner = "OpenSmalltalk";
34 repo = "opensmalltalk-vm";
35 tag = "202206021410";
36 hash = "sha256-QqElPiJuqD5svFjWrLz1zL0Tf+pHxQ2fPvkVRn2lyBI=";
37 };
38 in
39 stdenv.mkDerivation {
40 pname =
41 let
42 vmNameNoDots = builtins.replaceStrings [ "." ] [ "-" ] vmName;
43 in
44 "opensmalltalk-vm-${platformDir}-${vmNameNoDots}";
45 version = src.rev;
46
47 inherit src;
48
49 postPatch = ''
50 vmVersionFiles=$(sed -n 's/^versionfiles="\(.*\)"/\1/p' ./scripts/updateSCCSVersions)
51 for vmVersionFile in $vmVersionFiles; do
52 substituteInPlace "$vmVersionFile" \
53 --replace "\$Date\$" "\$Date: Thu Jan 1 00:00:00 1970 +0000 \$" \
54 --replace "\$URL\$" "\$URL: ${src.url} \$" \
55 --replace "\$Rev\$" "\$Rev: ${src.rev} \$" \
56 --replace "\$CommitHash\$" "\$CommitHash: 000000000000 \$"
57 done
58 patchShebangs --build ./building/${platformDir} scripts
59 substituteInPlace ./platforms/unix/config/mkmf \
60 --replace "/bin/rm" "rm"
61 substituteInPlace ./platforms/unix/config/configure \
62 --replace "/usr/bin/file" "file" \
63 --replace "/usr/bin/pkg-config" "pkg-config" \
64 '';
65
66 preConfigure = ''
67 cd building/${platformDir}/${vmName}/build
68 # Exits with non-zero code if the check fails, counterintuitively
69 ../../../../scripts/checkSCCSversion && exit 1
70 cp ../plugins.int ../plugins.ext .
71 configureFlagsArray=${configureFlagsArray}
72 '';
73
74 configureScript = "../../../../platforms/unix/config/configure";
75
76 configureFlags = [ "--with-scriptname=${scriptName}" ] ++ configureFlags;
77
78 buildFlags = [ "all" ];
79
80 enableParallelBuilding = true;
81
82 nativeBuildInputs = [
83 file
84 pkg-config
85 ];
86
87 buildInputs = [
88 alsa-lib
89 freetype
90 libpulseaudio
91 libtool
92 libuuid
93 openssl
94 pango
95 libx11
96 libxrandr
97 ];
98
99 postInstall = ''
100 rm "$out/squeak"
101 cd "$out/bin"
102 BIN="$(find ../lib -type f -name squeak)"
103 for f in $(find . -type f); do
104 rm "$f"
105 ln -s "$BIN" "$f"
106 done
107 '';
108
109 meta = {
110 description = "Cross-platform virtual machine for Squeak, Pharo, Cuis, and Newspeak";
111 mainProgram = scriptName;
112 homepage = "https://opensmalltalk.org/";
113 license = with lib.licenses; [ mit ];
114 maintainers = with lib.maintainers; [ jakewaksbaum ];
115 platforms = [ stdenv.targetPlatform.system ];
116 };
117 };
118
119 vmsByPlatform = {
120 "aarch64-linux" = {
121 "squeak-cog-spur" = buildVM {
122 platformDir = "linux64ARMv8";
123 vmName = "squeak.cog.spur";
124 scriptName = "squeak";
125 configureFlagsArray = ''
126 (
127 CFLAGS="-DNDEBUG -DDEBUGVM=0 -DMUSL -D_GNU_SOURCE -DUSEEVDEV -DCOGMTVM=0 -DDUAL_MAPPED_CODE_ZONE=1"
128 LIBS="-lrt"
129 )
130 '';
131 configureFlags = [
132 "--with-vmversion=5.0"
133 "--with-src=src/spur64.cog"
134 "--without-npsqueak"
135 "--enable-fast-bitblt"
136 ];
137 };
138
139 "squeak-stack-spur" = buildVM {
140 platformDir = "linux64ARMv8";
141 vmName = "squeak.stack.spur";
142 scriptName = "squeak";
143 configureFlagsArray = ''
144 (
145 CFLAGS="-DNDEBUG -DDEBUGVM=0 -DMUSL -D_GNU_SOURCE -DUSEEVDEV -D__ARM_ARCH_ISA_A64 -DARM64 -D__arm__ -D__arm64__ -D__aarch64__"
146 )
147 '';
148 configureFlags = [
149 "--with-vmversion=5.0"
150 "--with-src=src/spur64.stack"
151 "--disable-cogit"
152 "--without-npsqueak"
153 ];
154 };
155 };
156
157 "x86_64-linux" = {
158 "newspeak-cog-spur" = buildVM {
159 platformDir = "linux64x64";
160 vmName = "newspeak.cog.spur";
161 scriptName = "newspeak";
162 configureFlagsArray = ''
163 (
164 CFLAGS="-DNDEBUG -DDEBUGVM=0"
165 )
166 '';
167 configureFlags = [
168 "--with-vmversion=5.0"
169 "--with-src=src/spur64.cog.newspeak"
170 "--without-vm-display-fbdev"
171 "--without-npsqueak"
172 ];
173 };
174
175 "squeak-cog-spur" = buildVM {
176 platformDir = "linux64x64";
177 vmName = "squeak.cog.spur";
178 scriptName = "squeak";
179 configureFlagsArray = ''
180 (
181 CFLAGS="-DNDEBUG -DDEBUGVM=0 -DCOGMTVM=0"
182 )
183 '';
184 configureFlags = [
185 "--with-vmversion=5.0"
186 "--with-src=src/spur64.cog"
187 "--without-npsqueak"
188 ];
189 };
190 };
191 };
192
193 platform = stdenv.targetPlatform.system;
194in
195if (!config.allowAliases && !(vmsByPlatform ? platform)) then
196 # Don't throw without aliases to not break CI.
197 null
198else
199 vmsByPlatform.${platform} or (throw (
200 "Unsupported platform ${platform}: only the following platforms are supported: "
201 + toString (builtins.attrNames vmsByPlatform)
202 ))