···11+#!/bin/sh22+# This is based on the script by David T. Lewis posted here:33+# http://lists.squeakfoundation.org/pipermail/vm-dev/2017-April/024836.html44+#55+# VM run utility script66+# usage: run <myimage>77+#88+# Select a VM and run an image based on the image format number99+1010+# Search for the image filename in the command line arguments1111+for arg in $*; do1212+ case ${arg} in1313+ -*) # ignore1414+ ;;1515+ *) # either an option argument or the image name1616+ if test -f ${arg}; then1717+ magic=$(file -m @share@/magic "$arg")1818+ case "$magic" in1919+ 'Smalltalk image V3 32b*')2020+ image=${arg}2121+ vm=@cog-vm@/bin/pharo-cog2222+ ;;2323+ 'Smalltalk image Spur 32b*')2424+ image=${arg}2525+ vm=@spur-vm@/bin/pharo-spur2626+ ;;2727+ 'Smalltalk image Spur 64b*')2828+ if "@spur64-vm@" == "none"; then2929+ echo "error: detected 64-bit image but 64-bit VM is not available" >&23030+ exit 13131+ fi3232+ image=${arg}3333+ vm=@spur64-vm@/bin/pharo-spur643434+ ;;3535+ esac3636+ fi3737+ ;;3838+ esac3939+done4040+4141+# Extra arguments to pass to the VM4242+args=""4343+4444+# Print a message to explain our DWIM'ery.4545+if -n "$image"; then4646+ echo "using VM selected by image type."4747+ echo " image: $image"4848+ echo " type: $magic"4949+ echo " vm: $vm"5050+elif test "$#" == 0; then5151+ echo "using default vm and image; none specified on command line"5252+ args="@default-image@"5353+ # XXX Just assume this is the right VM (for pharo launcher)5454+ vm=@cog-vm@/bin/pharo-cog5555+else5656+ echo "using default vm; image type not detected"5757+fi5858+5959+# Run the VM6060+set -f6161+exec ${vm} $args "$@"6262+
+58
pkgs/development/pharo/wrapper/default.nix
···11+{ stdenv, file, makeDesktopItem, cog32, spur32, spur64 ? "none" }:22+33+stdenv.mkDerivation rec {44+ name = "pharo-vm";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.sh2222+ '';2323+ installPhase = ''2424+ mkdir -p $out/bin2525+ cp pharo-vm.sh $out/bin/pharo2626+ chmod +x $out/bin/pharo2727+ '';2828+ meta = {2929+ description = "Pharo virtual machine (multiple variants)";3030+3131+ longDescription = ''3232+ Pharo's goal is to deliver a clean, innovative, free open-source3333+ Smalltalk-inspired environment. By providing a stable and small core3434+ system, excellent dev tools, and maintained releases, Pharo is an3535+ attractive platform to build and deploy mission critical applications.3636+3737+ This package provides a front-end for starting the virtual3838+ machine. The command 'pharo-vm' automatically detects the type3939+ of image and executes a suitable virtual machine: CogV3, Spur,4040+ or Spur64. This makes it easy to open Pharo images because you4141+ do not have to worry about which virtual machine variant is4242+ 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+ intersectLists5454+ platforms.mesaPlatforms5555+ (subtractLists platforms.darwin platforms.unix);5656+ };5757+}5858+
···11+#!/bin/sh22+# This is based on the script by David T. Lewis posted here:33+# http://lists.squeakfoundation.org/pipermail/vm-dev/2017-April/024836.html44+#55+# VM run utility script66+# usage: run <myimage>77+#88+# Select a VM and run an image based on the image format number99+1010+PATH=$PATH:@file@/bin1111+1212+# Search for the image filename in the command line arguments1313+for arg in $* $SQUEAK_IMAGE; do1414+ case ${arg} in1515+ -*) # ignore1616+ ;;1717+ *) # either an option argument or the image name1818+ if test -e ${arg}; then1919+ magic=$(file -L -b -m @magic@ "$arg")2020+ case "$magic" in2121+ "Smalltalk image V3 32b"*)2222+ image=${arg}2323+ vm=@cog32@/bin/pharo-cog2424+ ;;2525+ "Smalltalk image Spur 32b"*)2626+ image=${arg}2727+ vm=@spur32@/bin/pharo-spur2828+ ;;2929+ "Smalltalk image Spur 64b"*)3030+ if [ "@spur64vm@" == "none" ]; then3131+ echo "error: detected 64-bit image but 64-bit VM is not available" >&23232+ exit 13333+ fi3434+ image=${arg}3535+ vm=@spur64@/bin/pharo-spur643636+ ;;3737+ esac3838+ fi3939+ ;;4040+ esac4141+done4242+4343+# Print a message to explain our DWIM'ery.4444+if [ -n "$image" ]; then4545+ echo "using VM selected by image type."4646+ echo " image: $image"4747+ echo " type: $magic"4848+ echo " vm: $vm"4949+else5050+ echo "using default vm; image type not detected"5151+ vm=@cog32@/bin/pharo-cog5252+fi5353+5454+# Run the VM5555+set -f5656+exec -- ${vm} $@5757+