19 { name, src, version, source-date, source-url, ... }:
22 stdenv.mkDerivation rec {
25 # Command line invocation name.
26 # Distinct name for 64-bit builds because they only work with 64-bit images.
27 cmd = if stdenv.is64bit then "pharo-spur64" else "pharo-spur";
29 # Choose desired VM sources. Separate for 32-bit and 64-bit VM.
30 # (Could extent to building more VM variants e.g. SpurV3, Sista, etc.)
31 vm = if stdenv.is64bit then "spur64src" else "spursrc";
33 # Choose target platform name in the format used by the vm.
35 if stdenv.isLinux && stdenv.isi686 then "linux32x86"
36 else if stdenv.isLinux && stdenv.isx86_64 then "linux64x64"
37 else if stdenv.isDarwin && stdenv.isi686 then "macos32x86"
38 else if stdenv.isDarwin && stdenv.isx86_64 then "macos64x64"
39 else throw "Unsupported platform: only Linux/Darwin x86/x64 are supported.";
41 # Shared data (for the sources file)
42 pharo-share = import ./share.nix { inherit lib stdenv fetchurl unzip; };
44 # Note: -fPIC causes the VM to segfault.
45 hardeningDisable = [ "format" "pic"
46 # while the VM depends on <= gcc48:
49 # gcc 4.8 used for the build:
51 # gcc5 crashes during compilation; gcc >= 4.9 produces a
52 # binary that crashes when forking a child process. See:
53 # http://forum.world.st/OSProcess-fork-issue-with-Debian-built-VM-td4947326.html
55 # (stack protection is disabled above for gcc 4.8 compatibility.)
56 nativeBuildInputs = [ autoreconfHook unzip ];
73 enableParallelBuilding = true;
75 # Regenerate the configure script.
76 # Unnecessary? But the build breaks without this.
78 pushd platforms/unix/config
83 # Configure with options modeled on the 'mvm' build script from the vm.
84 configureScript = "platforms/unix/config/configure";
85 configureFlags = [ "--without-npsqueak"
86 "--with-vmversion=5.0"
88 CFLAGS = "-DPharoVM -DIMMUTABILITY=1 -msse2 -D_GNU_SOURCE -DCOGMTVM=0 -g -O2 -DNDEBUG -DDEBUGVM=0";
89 LDFLAGS = "-Wl,-z,now";
91 # VM sources require some patching before build.
93 patchShebangs build.${flavor}
94 # Fix hard-coded path to /bin/rm in a script
95 sed -i -e 's:/bin/rm:rm:' platforms/unix/config/mkmf
96 # Fill in mandatory metadata about the VM source version
97 sed -i -e 's!\$Date\$!$Date: ${source-date} $!' \
98 -e 's!\$Rev\$!$Rev: ${version} $!' \
99 -e 's!\$URL\$!$URL: ${source-url} $!' \
100 platforms/Cross/vm/sqSCCSVersion.h
103 # Note: --with-vmcfg configure option is broken so copy plugin specs to ./
105 cp build."${flavor}"/pharo.cog.spur/plugins.{ext,int} .
108 # (No special build phase.)
123 # Install in working directory and then copy
124 make install-squeak install-plugins prefix=$(pwd)/products
126 # Copy binaries & rename from 'squeak' to 'pharo'
128 cp products/lib/squeak/5.0-*/squeak "$out/pharo"
129 cp -r products/lib/squeak/5.0-*/*.so "$out"
130 ln -s "${pharo-share}/lib/"*.sources "$out"
132 # Create a shell script to run the VM in the proper environment.
134 # These wrapper puts all relevant libraries into the
135 # LD_LIBRARY_PATH. This is important because various C code in the VM
136 # and Smalltalk code in the image will search for them there.
139 # Note: include ELF rpath in LD_LIBRARY_PATH for finding libc.
140 libs=$out:$(patchelf --print-rpath "$out/pharo"):${lib.makeLibraryPath libs}
143 cat > "$out/bin/${cmd}" <<EOF
146 LD_LIBRARY_PATH="\$LD_LIBRARY_PATH''${LD_LIBRARY_PATH:+:}$libs" exec $out/pharo "\$@"
148 chmod +x "$out/bin/${cmd}"
149 ln -s ${libgit2}/lib/libgit2.so* "$out/"
153 description = "Clean and innovative Smalltalk-inspired environment";
154 homepage = "https://pharo.org";
156 Pharo's goal is to deliver a clean, innovative, free open-source
157 Smalltalk-inspired environment. By providing a stable and small core
158 system, excellent dev tools, and maintained releases, Pharo is an
159 attractive platform to build and deploy mission critical applications.
161 This package provides the executable VM. You should probably not care
162 about this package (which represents a packaging detail) and have a
163 look at the pharo-vm-core package instead.
165 Please fill bug reports on http://bugs.pharo.org under the 'Ubuntu
166 packaging (ppa:pharo/stable)' project.
168 license = licenses.mit;
169 maintainers = [ maintainers.lukego ];
170 platforms = [ "i686-linux" "x86_64-linux" ];