diff --git a/pkgs/development/pharo/launcher/default.nix b/pkgs/development/pharo/launcher/default.nix index 911680b1eb8d..9cec6e81ae62 100644 --- a/pkgs/development/pharo/launcher/default.nix +++ b/pkgs/development/pharo/launcher/default.nix @@ -1,11 +1,11 @@ -{ stdenv, fetchurl, bash, pharo-vm, unzip, makeDesktopItem }: +{ stdenv, fetchurl, bash, pharo, unzip, makeDesktopItem }: stdenv.mkDerivation rec { - version = "0.2.9-2016.01.14"; + version = "2017.02.28"; name = "pharo-launcher-${version}"; src = fetchurl { - url = "http://files.pharo.org/platform/launcher/blessed/PharoLauncher-user-${version}.zip"; - sha256 = "0lzdnaw7l1rrzbrq53xsy38aiz6id5x7s78ds1dhb31vqc241yy8"; + url = "http://files.pharo.org/platform/launcher/PharoLauncher-user-stable-${version}.zip"; + sha256 = "1hfwjyx0c47s6ivc1zr2sf5mk1xw2zspsv0ns8mj3kcaglzqwiq0"; }; executable-name = "pharo-launcher"; @@ -23,7 +23,7 @@ stdenv.mkDerivation rec { # because upstream tarball has no top-level directory. sourceRoot = "."; - buildInputs = [ bash pharo-vm unzip ]; + buildInputs = [ bash pharo unzip ]; installPhase = '' mkdir -p $prefix/share/pharo-launcher @@ -37,8 +37,7 @@ stdenv.mkDerivation rec { cat > $prefix/bin/${executable-name} < $prefix/bin/pharo-cog < $prefix/bin/${binary-basename}-x < "$out/bin/${cmd}" < $prefix/bin/${binary-basename}-nox <= 4.9 produces a + # binary that crashes when forking a child process. See: + # http://forum.world.st/OSProcess-fork-issue-with-Debian-built-VM-td4947326.html + # + # (stack protection is disabled above for gcc 4.8 compatibility.) + buildInputs = [ bash unzip glibc openssl gcc48 mesa freetype xorg.libX11 xorg.libICE xorg.libSM alsaLib cairo pharo-share libuuid autoreconfHook ]; meta = { description = "Clean and innovative Smalltalk-inspired environment"; @@ -89,7 +122,7 @@ stdenv.mkDerivation rec { ''; homepage = http://pharo.org; license = stdenv.lib.licenses.mit; - maintainers = [ ]; + maintainers = [ stdenv.lib.maintainers.lukego ]; # Pharo VM sources are packaged separately for darwin (macOS) platforms = with stdenv.lib; intersectLists diff --git a/pkgs/development/pharo/vm/default.nix b/pkgs/development/pharo/vm/default.nix index aca5c37d2656..e6269503a4c4 100644 --- a/pkgs/development/pharo/vm/default.nix +++ b/pkgs/development/pharo/vm/default.nix @@ -1,27 +1,15 @@ -{ stdenv, fetchurl, cmake, bash, unzip, glibc, openssl, gcc, mesa, freetype, xorg, alsaLib, cairo, makeDesktopItem } @args: +{ stdenv, callPackage, callPackage_i686, makeWrapper, ...} @pkgs: + +let + i686 = callPackage_i686 ./vms.nix {}; + native = callPackage ./vms.nix {}; +in rec { - pharo-vm-build = import ./build-vm.nix args; - - base-url = http://files.pharo.org/vm/src/vm-unix-sources/blessed; - - pharo-no-spur = pharo-vm-build rec { - version = "2016.02.18"; - name = "pharo-vm-i386-${version}"; - binary-basename = "pharo-vm"; - src = fetchurl { - url = "${base-url}/pharo-vm-${version}.tar.bz2"; - sha256 = "16n2zg7v2s1ml0vvpbhkw6khmgn637sr0d7n2b28qm5yc8pfhcj4"; - }; - }; - - pharo-spur = pharo-vm-build rec { - version = "2016.07.16"; - name = "pharo-vm-spur-i386-${version}"; - binary-basename = "pharo-spur-vm"; - src = fetchurl { - url = "${base-url}/pharo-vm-spur-${version}.tar.bz2"; - sha256 = "07nk4w5wh7gcf27cch5paqp9zdlshnknpv4y7imxlkjd76viac2b"; - }; - }; + cog32 = i686.cog; + spur32 = i686.spur; + spur64 = if stdenv.is64bit then native.spur else "none"; + multi-vm-wrapper = callPackage ../wrapper { inherit cog32 spur32 spur64; }; } + + diff --git a/pkgs/development/pharo/vm/share.nix b/pkgs/development/pharo/vm/share.nix index aba42e3981cb..54e686c82feb 100644 --- a/pkgs/development/pharo/vm/share.nix +++ b/pkgs/development/pharo/vm/share.nix @@ -31,6 +31,11 @@ stdenv.mkDerivation rec { sha256 = "0ykl1y0a4yy5qn8fwz0wkl8fcn4pqv9q0w0r2llhzdz3jdg1k69g"; }; + sources60Zip = fetchurl { + url = http://files.pharo.org/sources/PharoV60.sources.zip; + sha256 = "0xbdi679ryb2zg412xy6zkh22l20pmbl92m3qhfgzjvgybna8z2a"; + }; + buildInputs = [ unzip ]; installPhase = '' @@ -43,6 +48,7 @@ stdenv.mkDerivation rec { unzip ${sources30Zip} -d $prefix/lib/ unzip ${sources40Zip} -d $prefix/lib/ unzip ${sources50Zip} -d $prefix/lib/ + unzip ${sources60Zip} -d $prefix/lib/ ''; meta = { diff --git a/pkgs/development/pharo/vm/vms.nix b/pkgs/development/pharo/vm/vms.nix new file mode 100644 index 000000000000..5258f4f6e77b --- /dev/null +++ b/pkgs/development/pharo/vm/vms.nix @@ -0,0 +1,46 @@ +{ cmake, stdenv, fetchurl, bash, unzip, glibc, openssl, gcc, mesa, freetype, xorg, alsaLib, cairo, libuuid, autoreconfHook, gcc48, fetchFromGitHub, makeWrapper} @args: + +let + pharo-vm-build = import ./build-vm.nix args; + pharo-vm-build-legacy = import ./build-vm-legacy.nix args; +in + +let suffix = if stdenv.is64bit then "64" else "32"; in + +rec { + # Build the latest VM + spur = pharo-vm-build rec { + name = "pharo-spur${suffix}"; + version = "git.${revision}"; + src = fetchFromGitHub { + owner = "pharo-project"; + repo = "pharo-vm"; + rev = revision; + sha256 = "0dkiy5fq1xn2n93cwf767xz24c01ic0wfw94jk9nvn7pmcfj7m62"; + }; + # This metadata will be compiled into the VM and introspectable + # from Smalltalk. This has been manually extracted from 'git log'. + # + # The build would usually generate this automatically using + # opensmalltalk-vm/.git_filters/RevDateURL.smudge but that script + # is too impure to run from nix. + revision = "6a63f68a3dd4deb7c17dd2c7ac6e4dd4b0b6d937"; + source-date = "Tue May 30 19:41:27 2017 -0700"; + source-url = "https://github.com/pharo-project/pharo-vm"; + }; + + # Build an old ("legacy") CogV3 VM for running pre-spur images. + # (Could be nicer to build the latest VM in CogV3 mode but this is + # not supported on the Pharo VM variant at the moment.) + cog = pharo-vm-build-legacy rec { + version = "2016.02.18"; + name = "pharo-cog${suffix}"; + base-url = http://files.pharo.org/vm/src/vm-unix-sources/blessed; + src = fetchurl { + url = "${base-url}/pharo-vm-${version}.tar.bz2"; + sha256 = "16n2zg7v2s1ml0vvpbhkw6khmgn637sr0d7n2b28qm5yc8pfhcj4"; + }; + }; + +} + diff --git a/pkgs/development/pharo/wrapper/default.nix b/pkgs/development/pharo/wrapper/default.nix new file mode 100644 index 000000000000..f60b8a6d2038 --- /dev/null +++ b/pkgs/development/pharo/wrapper/default.nix @@ -0,0 +1,58 @@ +{ stdenv, file, makeDesktopItem, cog32, spur32, spur64 ? "none" }: + +stdenv.mkDerivation rec { + name = "pharo"; + src = ./.; + inherit cog32 spur32 spur64 file; + magic = ./magic; + desktopItem = makeDesktopItem { + inherit name; + desktopName = "Pharo VM"; + genericName = "Pharo Virtual Machine"; + exec = "pharo %F"; + icon = "pharo"; + terminal = "false"; + type="Application"; + startupNotify = "false"; + categories = "Development;"; + mimeType = "application/x-pharo-image"; + }; + buildPhase = '' + substituteAllInPlace ./pharo-vm.sh + ''; + installPhase = '' + mkdir -p $out/bin + cp pharo-vm.sh $out/bin/pharo + chmod +x $out/bin/pharo + ''; + meta = { + description = "Pharo virtual machine (multiple variants)"; + + longDescription = '' + Pharo's goal is to deliver a clean, innovative, free open-source + Smalltalk-inspired environment. By providing a stable and small core + system, excellent dev tools, and maintained releases, Pharo is an + attractive platform to build and deploy mission critical applications. + + This package provides a front-end for starting the virtual + machine. The command 'pharo-vm' automatically detects the type + of image and executes a suitable virtual machine: CogV3, Spur, + or Spur64. This makes it easy to open Pharo images because you + do not have to worry about which virtual machine variant is + required. + + More about the Cog family of virtual machines: + http://www.mirandabanda.org/cogblog/about-cog/ + ''; + + homepage = http://pharo.org; + license = stdenv.lib.licenses.mit; + maintainers = [ stdenv.lib.maintainers.lukego ]; + # Pharo VM sources are packaged separately for darwin (OS X) + platforms = with stdenv.lib; + intersectLists + platforms.mesaPlatforms + (subtractLists platforms.darwin platforms.unix); + }; +} + diff --git a/pkgs/development/pharo/wrapper/magic b/pkgs/development/pharo/wrapper/magic new file mode 100644 index 000000000000..3870ef2dd01c --- /dev/null +++ b/pkgs/development/pharo/wrapper/magic @@ -0,0 +1,37 @@ +# Smalltalk image file formats +0 lelong 6502 Smalltalk image V3 32b (%d) +!:mime application/squeak-image +0 belong 6502 Smalltalk image V3 32b (%d) +!:mime application/squeak-image +0 lelong 6504 Smalltalk image V3 32b +C (%d) +!:mime application/cog-image +0 belong 6504 Smalltalk image V3 32b +C (%d) +!:mime application/cog-image +0 lelong 68000 Smalltalk image V3 64b (%d) +!:mime application/squeak64-image +4 belong 68000 Smalltalk image V3 64b (%d) +!:mime application/squeak64-image +0 lelong 68002 Smalltalk image V3 64b +C (%d) +!:mime application/cog64-image +4 belong 68002 Smalltalk image V3 64b +C (%d) +!:mime application/cog64-image +0 lelong 6505 Smalltalk image V3 32b +C+NF (%d) +!:mime application/cog-image +0 belong 6505 Smalltalk image V3 32b +C+NF (%d) +!:mime application/cog-image +0 lelong 68003 Smalltalk image V3 64b +C+NF (%d) +!:mime application/cog64-image +4 belong 68003 Smalltalk image V3 64b +C+NF (%d) +!:mime application/cog64-image +0 lelong 6521 Smalltalk image Spur 32b +C+NF (%d) +!:mime application/spur-image +0 belong 6521 Smalltalk image Spur 32b +C+NF (%d) +!:mime application/spur-image +0 lelong 68019 Smalltalk image Spur 64b +C+NF (%d) +!:mime application/spur64-image +4 belong 68019 Smalltalk image Spur 64b +C+NF (%d) +!:mime application/spur64-image +0 lelong 68021 Smalltalk image Spur 64b +C+NF+Tag (%d) +!:mime application/spur64-image +4 belong 68021 Smalltalk image Spur 64b +C+NF+Tag (%d) +!:mime application/spur64-image diff --git a/pkgs/development/pharo/wrapper/pharo-vm.sh b/pkgs/development/pharo/wrapper/pharo-vm.sh new file mode 100644 index 000000000000..d5bd1a2d8018 --- /dev/null +++ b/pkgs/development/pharo/wrapper/pharo-vm.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# This is based on the script by David T. Lewis posted here: +# http://lists.squeakfoundation.org/pipermail/vm-dev/2017-April/024836.html +# +# VM run utility script +# usage: run +# +# Select a VM and run an image based on the image format number + +PATH=$PATH:@file@/bin + +# Search for the image filename in the command line arguments +for arg in $* $SQUEAK_IMAGE; do + case ${arg} in + -*) # ignore + ;; + *) # either an option argument or the image name + if test -e ${arg}; then + magic=$(file -L -b -m @magic@ "$arg") + case "$magic" in + "Smalltalk image V3 32b"*) + image=${arg} + vm=@cog32@/bin/pharo-cog + ;; + "Smalltalk image Spur 32b"*) + image=${arg} + vm=@spur32@/bin/pharo-spur + ;; + "Smalltalk image Spur 64b"*) + if [ "@spur64vm@" == "none" ]; then + echo "error: detected 64-bit image but 64-bit VM is not available" >&2 + exit 1 + fi + image=${arg} + vm=@spur64@/bin/pharo-spur64 + ;; + esac + fi + ;; + esac +done + +# Print a message to explain our DWIM'ery. +if [ -n "$image" ]; then + echo "using VM selected by image type." + echo " image: $image" + echo " type: $magic" + echo " vm: $vm" +else + echo "using default vm; image type not detected" + vm=@cog32@/bin/pharo-cog +fi + +# Run the VM +set -f +exec -- "${vm}" "$@" + diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 1dc5ca208d1b..090a44009a1d 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -6580,10 +6580,11 @@ with pkgs; guile-xcb = callPackage ../development/guile-modules/guile-xcb { }; - pharo-vms = callPackage_i686 ../development/pharo/vm { }; - pharo-vm = pharo-vms.pharo-no-spur; - pharo-vm5 = pharo-vms.pharo-spur; - + pharo-vms = callPackage ../development/pharo/vm { }; + pharo = pharo-vms.multi-vm-wrapper; + pharo-cog32 = pharo-vms.cog32; + pharo-spur32 = pharo-vms.spur32; + pharo-spur64 = assert stdenv.is64bit; pharo-vms.spur64; pharo-launcher = callPackage ../development/pharo/launcher { }; srecord = callPackage ../development/tools/misc/srecord { };