1{ lib, stdenv, fetchurl, bash, pharo, unzip, makeDesktopItem }:
2
3stdenv.mkDerivation rec {
4 version = "2017.02.28";
5 pname = "pharo-launcher";
6 src = fetchurl {
7 url = "http://files.pharo.org/platform/launcher/PharoLauncher-user-stable-${version}.zip";
8 sha256 = "1hfwjyx0c47s6ivc1zr2sf5mk1xw2zspsv0ns8mj3kcaglzqwiq0";
9 };
10
11 executable-name = "pharo-launcher";
12
13 desktopItem = makeDesktopItem {
14 name = "Pharo";
15 exec = executable-name;
16 icon = "pharo";
17 comment = "Launcher for Pharo distributions";
18 desktopName = "Pharo";
19 genericName = "Pharo";
20 categories = [ "Development" ];
21 };
22
23 # because upstream tarball has no top-level directory.
24 sourceRoot = ".";
25
26 nativeBuildInputs = [ unzip ];
27 buildInputs = [ bash pharo ];
28
29 installPhase = ''
30 mkdir -p $prefix/share/pharo-launcher
31 mkdir -p $prefix/bin
32
33 mv PharoLauncher.image $prefix/share/pharo-launcher/pharo-launcher.image
34 mv PharoLauncher.changes $prefix/share/pharo-launcher/pharo-launcher.changes
35
36 mkdir -p $prefix/share/applications
37 cp "${desktopItem}/share/applications/"* $out/share/applications
38
39 cat > $prefix/bin/${executable-name} <<EOF
40 #!${bash}/bin/bash
41 exec "${pharo}/bin/pharo" $prefix/share/pharo-launcher/pharo-launcher.image
42 EOF
43 chmod +x $prefix/bin/${executable-name}
44 '';
45
46 doCheck = true;
47
48 checkPhase = ''
49 # Launcher should be able to run for a few seconds without crashing.
50 (set +e
51 export HOME=. # Pharo will try to create files here
52 secs=5
53 echo -n "Running headless Pharo for $secs seconds to check for a crash... "
54 timeout $secs \
55 "${pharo}/bin/pharo" --nodisplay PharoLauncher.image --no-quit eval 'true'
56 test "$?" == 124 && echo "ok")
57 '';
58
59 meta = with lib; {
60 description = "Launcher for Pharo distributions";
61 homepage = "https://pharo.org";
62 longDescription = ''
63 Pharo's goal is to deliver a clean, innovative, free open-source
64 Smalltalk-inspired environment. By providing a stable and small
65 core system, excellent dev tools, and maintained releases, Pharo
66 is an attractive platform to build and deploy mission critical
67 applications.
68
69 The Pharo Launcher is a cross-platform application that
70 - lets you manage your Pharo images (launch, rename, copy and delete);
71 - lets you download image templates (i.e., zip archives) from many
72 different sources (e.g., Jenkins, files.pharo.org);
73 - lets you create new images from any template.
74
75 The idea behind the Pharo Launcher is that you should be able to
76 access it very rapidly from your OS application launcher. As a
77 result, launching any image is never more than 3 clicks away.
78 '';
79 license = licenses.mit;
80 maintainers = [ ];
81 platforms = pharo.meta.platforms;
82 };
83}