anchor.diff:        xorg.libX11
       ];
   
  +    redirects = [
  +      "/usr/bin/gksudo=${gksu}/bin/gksudo"
  +      "/usr/bin/pkexec=${pkexecPath}"
  +    ];
  +
  +    postPhase =
  +      /* Fix paths */ ''
  +        sed -i sublime_text.desktop \
  +          -e 's,/opt/sublime_text/,,' \
  +          -e 's,sublime-text,sublime_text,'
  +      '' +
  +      /* Rename icon file */ ''
  +        mv -v Icon/256x256/sublime-text.png Icon/256x256/sublime_text.png
  +      '';
  +
       buildPhase = ''
  -      for i in sublime_text plugin_host crash_reporter ; do
  +      for i in 'sublime_text' 'plugin_host' 'crash_reporter' ; do
           patchelf \
             --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
  -          --set-rpath ${libPath}:${stdenv.cc.cc}/lib${optionalString is64bit "64"} \
  +          --set-rpath ${libPath}:${stdenv.cc.cc}/lib64 \
             $i
         done
  +    '' +
  +    /* Rewrite gksudo/pkexec argument. Note that we can't delete
  +       bytes in binary. */ ''
  +      sed -i sublime_text \
  +        -e 's,/bin/cp\x00,cp\x00\x00\x00\x00\x00\x00,g'
       '';
   
       installPhase = ''
  -      mkdir -p $out/
  +      mkdir -pv $out/
         cp -prvd * $out/
  -
  -      # Without this, plugin_host crashes, even though it has the rpath
  -      wrapProgram \
  -        $out/plugin_host \
  -        --prefix LD_PRELOAD : ${stdenv.cc.cc}/lib${optionalString is64bit "64"}/libgcc_s.so.1:${openssl}/lib/libssl.so:${bzip2}/lib/libbz2.so
  +    '' + ''
  +      wrapProgram $out/sublime_text \
  +        --set LD_PRELOAD '${libredirect}/lib/libredirect.so' \
  +        --set NIX_REDIRECTS ${builtins.concatStringsSep ":" redirects}
  +    '' +
  +    /* Without this, plugin_host crashes, even though it has the rpath */ ''
  +      wrapProgram $out/plugin_host \
  +        --prefix LD_PRELOAD : '${stdenv.cc.cc}/li64/libgcc_s.so.1' \
  +        --prefix LD_PRELOAD : '${openssl}/lib/libssl.so' \
  +        --prefix LD_PRELOAD : '${bzip2}/lib/libbz2.so'
       '';
   
       dontStrip = true;
       dontPatchELF = true;
  -    enableParallelBuilding = true;
     };
   in
   
  
positive.code:     ];
      license = licenses.unfreeRedistributable;
      platforms = [
        "i686-linux"
        "x86_64-linux"
      ];
    };
  
negative.code:   ];
  
    installPhase = ''
      mkdir -pv $out/bin
      ln -sv ${sublime-text-bin}/sublime_text $out/bin/sublime_text
      ln -sv ${sublime-text-bin}/sublime_text $out/bin/subl
  
      mkdir -pv $out/share/applications
      ln -sv ${sublime-text-bin}/sublime_text.desktop $out/share/applications
      mkdir -pv $out/share/icons
      ln -sv ${sublime-text-bin}/Icon/256x256/sublime_text.png $out/share/icons
    '';
  
    meta = with stdenv.lib; {
      description = "Sophisticated text editor for code, markup and prose";
  