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