[Nix-dev] Eclipse again

Marc Weber marco-oweber at gmx.de
Wed Apr 28 23:49:34 CEST 2010


I prepared this minimal patch I can agree on:

commit cec1f4517a825c71a12d8b961248af0fc93822ee
Author: Marc Weber <marco-oweber at gmx.de>
Date:   Wed Apr 28 23:43:29 2010 +0200

    add Eclipse note. Make the wrapper runnable outside of /nix/store

diff --git a/pkgs/applications/editors/eclipse/default.nix b/pkgs/applications/editors/eclipse/default.nix
index 225c94f..aacbf89 100644
--- a/pkgs/applications/editors/eclipse/default.nix
+++ b/pkgs/applications/editors/eclipse/default.nix
@@ -3,6 +3,64 @@
 , glib, gtk, libXtst, jre
 }:
 
+/*
+
+  Note: Eclipse stores various Eclipse instance specific data in ~/.eclipse/*-instance/...
+  The '*' depends on the executable location of Eclipse.
+
+  So if an Eclipse dependency such as gtk changes a different Eclipse setup directory will be used and
+  the plugins and update site list and more global settings seem to be gone.
+
+  Staring Eclipse from ~/.nix-profile/bin/eclipse doesn't help.
+
+  So I suggest copying the store path to ~/eclipse and run ~/eclipse/bin/eclipse instead.
+
+  However this still has some drawbacks: If you run nix-collect-garbage the gtk
+  libs the wrapper refers to might be gone. It should be easy for you to
+  replace the imortant lines in the wrapper.
+
+  You can also put this eclipse wrapper script (which was removed from
+  all-packages.nix -r 18458)
+  to your packageOverrides section and use that to run eclipse/eclipse.
+
+  Its parameterized by system because you may want to run both: i686 and x86_64 systems.
+
+    eclipseRunner =
+      pkgs.stdenv.mkDerivation {
+      name = "nix-eclipse-runner-script-${stdenv.system}";
+
+      phases = "installPhase";
+      installPhase = ''
+        ensureDir $out/bin
+        target=$out/bin/nix-run-eclipse-${stdenv.system}
+        cat > $target << EOF
+        #!/bin/sh
+        export PATH=${pkgs.jre}/bin:\$PATH
+        export LD_LIBRARY_PATH=${pkgs.gtkLibs216.glib}/lib:${pkgs.gtkLibs216.gtk}/lib:${pkgs.xlibs.libXtst}/lib
+        # If you run out of XX space try these? -vmargs -Xms512m -Xmx2048m -XX:MaxPermSize=256m
+        eclipse="\$1"; shift
+        exec \$eclipse -vmargs -Xms512m -Xmx2048m -XX:MaxPermSize=256m "\$@"
+        EOF
+        chmod +x $target
+      '';
+
+      meta = { 
+        description = "provide environment to run Eclipse";
+        longDescription = ''
+          Is there one distribution providing support for up to date Eclipse installations?
+          There are various reasons why not.
+          Installing binaries just works. Get Eclipse binaries form eclipse.org/downloads
+          install this wrapper then run Eclipse like this:
+          nix-run-eclipse $PATH_TO_ECLIPSE/eclipse/eclipse
+          and be happy. Everything works including update sites.
+        '';
+        maintainers = [pkgs.lib.maintainers.marcweber];
+        platforms = pkgs.lib.platforms.linux;
+      };
+    };
+
+
+*/
+
 assert stdenv ? glibc;
 
 stdenv.mkDerivation rec {
@@ -50,6 +108,9 @@ stdenv.mkDerivation rec {
     # Create desktop item
     ensureDir $out/share/applications
     cp ${desktopItem}/share/applications/* $out/share/applications
+  
+    # ensure eclipse can be run after copying the store path somewhere else..
+    sed -e 's=exec[ ]*[^ ]*=exec $(dirname $0)/../eclipse/eclipse =' -i $out/bin/eclipse
   '';
 
   meta = {


It does two things:
  a) tell everybody about some problems
  b) make the bin/eclipse wrapper work even when you move the store path.
  c) tells you that you could use a wrapper

However I don't think that most people will stumble upon that note.
Which is the best way to make that happen?
echo it whenever starting Eclipse?


There is a -configuration option for Eclipse. However when starting
Eclipse using that which indeed creates ~/.eclipse-org.eclipse.platform/
but contents look differently:

~/.eclipse/a-dir/: 

org.eclipse.platform_3.5.0_1062579763 i%ls
artifacts.xml  configuration  p2

~/.eclipse-org.eclipse.platform:
  config.ini		  org.eclipse.equinox.app  org.eclipse.ui.intro.universal
  org.eclipse.core.runtime  org.eclipse.osgi	   org.eclipse.update


So -configuration doesn't seem to solve it. (I'm not a Eclipse equinox
p2 expert - and I don't want to become one)

I don't like the current situation because if you don't copy the eclipse
store path into your personal directory your plugin setup can vanish
when gtk changes.. I don't think that's what we want.

People will try nix-env -iA eclipse and be happy to get it .. until
their setup is gone. How would you handle this?

Can you suggest a better solution ?

How do feel about readding the wrapper c) ?
Eelco Dolstra removed it in the past -r 18458.
That time he didn't want me to put it in again for a reason I don't
remember.
I'd like to see it come back for the reasons you can read up in
the comment. What about you?

Marc Weber



More information about the nix-dev mailing list