···11+{ cmake, stdenv, fetchurl, bash, unzip, glibc, openssl, gcc, mesa, freetype, xorg, alsaLib, cairo, libuuid, autoreconfHook, gcc48, fetchFromGitHub, makeWrapper} @args:
22+33+let
44+ pharo-vm-build = import ./build-vm.nix args;
55+ pharo-vm-build-legacy = import ./build-vm-legacy.nix args;
66+in
77+88+let suffix = if stdenv.is64bit then "64" else "32"; in
99+1010+rec {
1111+ # Build the latest VM
1212+ spur = pharo-vm-build rec {
1313+ name = "pharo-spur${suffix}";
1414+ version = "git.${revision}";
1515+ src = fetchFromGitHub {
1616+ owner = "pharo-project";
1717+ repo = "pharo-vm";
1818+ rev = revision;
1919+ sha256 = "0dkiy5fq1xn2n93cwf767xz24c01ic0wfw94jk9nvn7pmcfj7m62";
2020+ };
2121+ # This metadata will be compiled into the VM and introspectable
2222+ # from Smalltalk. This has been manually extracted from 'git log'.
2323+ #
2424+ # The build would usually generate this automatically using
2525+ # opensmalltalk-vm/.git_filters/RevDateURL.smudge but that script
2626+ # is too impure to run from nix.
2727+ revision = "6a63f68a3dd4deb7c17dd2c7ac6e4dd4b0b6d937";
2828+ source-date = "Tue May 30 19:41:27 2017 -0700";
2929+ source-url = "https://github.com/pharo-project/pharo-vm";
3030+ };
3131+3232+ # Build an old ("legacy") CogV3 VM for running pre-spur images.
3333+ # (Could be nicer to build the latest VM in CogV3 mode but this is
3434+ # not supported on the Pharo VM variant at the moment.)
3535+ cog = pharo-vm-build-legacy rec {
3636+ version = "2016.02.18";
3737+ name = "pharo-cog${suffix}";
3838+ base-url = http://files.pharo.org/vm/src/vm-unix-sources/blessed;
3939+ src = fetchurl {
4040+ url = "${base-url}/pharo-vm-${version}.tar.bz2";
4141+ sha256 = "16n2zg7v2s1ml0vvpbhkw6khmgn637sr0d7n2b28qm5yc8pfhcj4";
4242+ };
4343+ };
4444+4545+}
4646+
+58
pkgs/development/pharo/wrapper/default.nix
···11+{ stdenv, file, makeDesktopItem, cog32, spur32, spur64 ? "none" }:
22+33+stdenv.mkDerivation rec {
44+ name = "pharo";
55+ src = ./.;
66+ inherit cog32 spur32 spur64 file;
77+ magic = ./magic;
88+ desktopItem = makeDesktopItem {
99+ inherit name;
1010+ desktopName = "Pharo VM";
1111+ genericName = "Pharo Virtual Machine";
1212+ exec = "pharo %F";
1313+ icon = "pharo";
1414+ terminal = "false";
1515+ type="Application";
1616+ startupNotify = "false";
1717+ categories = "Development;";
1818+ mimeType = "application/x-pharo-image";
1919+ };
2020+ buildPhase = ''
2121+ substituteAllInPlace ./pharo-vm.sh
2222+ '';
2323+ installPhase = ''
2424+ mkdir -p $out/bin
2525+ cp pharo-vm.sh $out/bin/pharo
2626+ chmod +x $out/bin/pharo
2727+ '';
2828+ meta = {
2929+ description = "Pharo virtual machine (multiple variants)";
3030+3131+ longDescription = ''
3232+ Pharo's goal is to deliver a clean, innovative, free open-source
3333+ Smalltalk-inspired environment. By providing a stable and small core
3434+ system, excellent dev tools, and maintained releases, Pharo is an
3535+ attractive platform to build and deploy mission critical applications.
3636+3737+ This package provides a front-end for starting the virtual
3838+ machine. The command 'pharo-vm' automatically detects the type
3939+ of image and executes a suitable virtual machine: CogV3, Spur,
4040+ or Spur64. This makes it easy to open Pharo images because you
4141+ do not have to worry about which virtual machine variant is
4242+ required.
4343+4444+ More about the Cog family of virtual machines:
4545+ http://www.mirandabanda.org/cogblog/about-cog/
4646+ '';
4747+4848+ homepage = http://pharo.org;
4949+ license = stdenv.lib.licenses.mit;
5050+ maintainers = [ stdenv.lib.maintainers.lukego ];
5151+ # Pharo VM sources are packaged separately for darwin (OS X)
5252+ platforms = with stdenv.lib;
5353+ intersectLists
5454+ platforms.mesaPlatforms
5555+ (subtractLists platforms.darwin platforms.unix);
5656+ };
5757+}
5858+
···11+#!/bin/sh
22+# This is based on the script by David T. Lewis posted here:
33+# http://lists.squeakfoundation.org/pipermail/vm-dev/2017-April/024836.html
44+#
55+# VM run utility script
66+# usage: run <myimage>
77+#
88+# Select a VM and run an image based on the image format number
99+1010+PATH=$PATH:@file@/bin
1111+1212+# Search for the image filename in the command line arguments
1313+for arg in $* $SQUEAK_IMAGE; do
1414+ case ${arg} in
1515+ -*) # ignore
1616+ ;;
1717+ *) # either an option argument or the image name
1818+ if test -e ${arg}; then
1919+ magic=$(file -L -b -m @magic@ "$arg")
2020+ case "$magic" in
2121+ "Smalltalk image V3 32b"*)
2222+ image=${arg}
2323+ vm=@cog32@/bin/pharo-cog
2424+ ;;
2525+ "Smalltalk image Spur 32b"*)
2626+ image=${arg}
2727+ vm=@spur32@/bin/pharo-spur
2828+ ;;
2929+ "Smalltalk image Spur 64b"*)
3030+ if [ "@spur64vm@" == "none" ]; then
3131+ echo "error: detected 64-bit image but 64-bit VM is not available" >&2
3232+ exit 1
3333+ fi
3434+ image=${arg}
3535+ vm=@spur64@/bin/pharo-spur64
3636+ ;;
3737+ esac
3838+ fi
3939+ ;;
4040+ esac
4141+done
4242+4343+# Print a message to explain our DWIM'ery.
4444+if [ -n "$image" ]; then
4545+ echo "using VM selected by image type."
4646+ echo " image: $image"
4747+ echo " type: $magic"
4848+ echo " vm: $vm"
4949+else
5050+ echo "using default vm; image type not detected"
5151+ vm=@cog32@/bin/pharo-cog
5252+fi
5353+5454+# Run the VM
5555+set -f
5656+exec -- "${vm}" "$@"
5757+