sublime3: fix plugin_host (close #2804)

Also move the binaries in their own package, so it doesn't pollute the
profile.

authored by Wout Mertens and committed by Vladimír Čunát d619f0ef f8e108c8

+52 -29
+52 -29
pkgs/applications/editors/sublime3/default.nix
··· 1 - { fetchurl, stdenv, glib, xlibs, cairo, gtk, pango}: 1 + { fetchurl, stdenv, glib, xlibs, cairo, gtk, pango, makeWrapper}: 2 + 3 + assert stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux"; 4 + 2 5 let 6 + build = "3059"; 3 7 libPath = stdenv.lib.makeLibraryPath [glib xlibs.libX11 gtk cairo pango]; 4 - in 5 - assert stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux"; 8 + in let 9 + # package with just the binaries 10 + sublime = stdenv.mkDerivation { 11 + name = "sublimetext3-${build}-bin"; 12 + 13 + src = 14 + if stdenv.system == "i686-linux" then 15 + fetchurl { 16 + name = "sublimetext-3.0.59.tar.bz2"; 17 + url = "http://c758482.r82.cf2.rackcdn.com/sublime_text_3_build_${build}_x32.tar.bz2"; 18 + sha256 = "5ee7b42b5db057108e97b86fd408124fc3f7b56662b2851f59d91f8f0c288088"; 19 + } 20 + else 21 + fetchurl { 22 + name = "sublimetext-3.0.59.tar.bz2"; 23 + url = "http://c758482.r82.cf2.rackcdn.com/sublime_text_3_build_${build}_x64.tar.bz2"; 24 + sha256 = "da3039687664d33a734cea0151b2291ece9c7f35e5b73df5b2b5eac28a20b972"; 25 + }; 26 + 27 + dontStrip = true; 28 + dontPatchELF = true; 29 + buildInputs = [ makeWrapper ]; 30 + 31 + buildPhase = '' 32 + for i in sublime_text plugin_host crash_reporter; do 33 + patchelf \ 34 + --interpreter "$(cat $NIX_GCC/nix-support/dynamic-linker)" \ 35 + --set-rpath ${libPath}:${stdenv.gcc.gcc}/lib${stdenv.lib.optionalString stdenv.is64bit "64"} \ 36 + $i 37 + done 38 + ''; 39 + 40 + installPhase = '' 41 + mkdir -p $out 42 + cp -prvd * $out/ 43 + # Without this, plugin_host crashes, even though it has the rpath 44 + wrapProgram $out/plugin_host --prefix LD_PRELOAD : ${stdenv.gcc.gcc}/lib${stdenv.lib.optionalString stdenv.is64bit "64"}/libgcc_s.so.1 45 + ''; 46 + }; 47 + in stdenv.mkDerivation { 48 + name = "sublimetext3-${build}"; 6 49 7 - stdenv.mkDerivation rec { 8 - name = "sublimetext3-3.0.59"; 9 - src = 10 - if stdenv.system == "i686-linux" then 11 - fetchurl { 12 - name = "sublimetext-3.0.59.tar.bz2"; 13 - url = http://c758482.r82.cf2.rackcdn.com/sublime_text_3_build_3059_x32.tar.bz2; 14 - sha256 = "5ee7b42b5db057108e97b86fd408124fc3f7b56662b2851f59d91f8f0c288088"; 15 - } 16 - else 17 - fetchurl { 18 - name = "sublimetext-3.0.59.tar.bz2"; 19 - url = http://c758482.r82.cf2.rackcdn.com/sublime_text_3_build_3059_x64.tar.bz2; 20 - sha256 = "da3039687664d33a734cea0151b2291ece9c7f35e5b73df5b2b5eac28a20b972"; 21 - }; 22 - buildCommand = '' 23 - tar xvf ${src} 50 + phases = [ "installPhase" ]; 51 + installPhase = '' 24 52 mkdir -p $out/bin 25 - mv sublime_text_3 $out/sublime 26 - ln -s $out/sublime/sublime_text $out/bin/sublime 27 - ln -s $out/sublime/sublime_text $out/bin/sublime3 28 - 29 - echo ${libPath} 30 - patchelf \ 31 - --interpreter "$(cat $NIX_GCC/nix-support/dynamic-linker)" \ 32 - --set-rpath ${libPath}:${stdenv.gcc.gcc}/lib${stdenv.lib.optionalString stdenv.is64bit "64"} \ 33 - $out/sublime/sublime_text 53 + ln -s ${sublime}/sublime_text $out/bin/sublime 54 + ln -s ${sublime}/sublime_text $out/bin/sublime3 34 55 ''; 35 56 36 57 meta = { 37 58 description = "Sophisticated text editor for code, markup and prose"; 59 + maintainers = stdenv.lib.maintainers.wmertens; 38 60 license = "unfree"; 39 61 }; 40 62 } 63 +