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