Creating a custom Eclipse installation with a Github Project

Hello everyone,

I am currently looking to install Eclipse on my NixOS (20.09) machine to use it for developing and working with a Domain Specific Language (DSL). I have a set of installation instructions which of course are not tailored towards use with NixOS (but I’m used to that by now). Basically, the instructions require me to create a custom Eclipse installation via their GUI-only Oomph installer, selecting a specific base version of Eclipse (Eclipse for DSL developers) and adding the Github Project to it.

But that poses numerous problems to me:

  1. From what I gather, the current version of Eclipse is 2021-03, the stable nixpkgs branch only offers the one year older 2020-03 version.
  2. The Eclipse versions in the nixpks don’t contain the eclipse-dsl package, neither the 20.09 nor the unstable branch.
  3. Adding the Github Project is done at install-time and besides myself no one will need it in the forseeable future I guess. (meaning no-one has provided *.nix files for that)

I have teeth-gnashingly tried to use their GUI installer, but I saw in the derivations in nixpkgs that the binary would probably have to be patched, just like eclipse itself, so I gave up on that as I don’t want to manually keep the application up to date and patch it manually every time.
For starters I would probably be happy to just solve problems 1 and 2, installing a working and current eclipse-dsl package. Automatically installing the Github Project would then just be icing on the cake and will probably require a bit of fiddling with the Eclipse environment, so I’ll keep this for later.

I know that I could effectively just submit a PR to the nixpkgs repo adding a eclipses.eclipse-dsl derivation (and bumping the version of all Eclipses in the process). But I would like to create this derivation for myself first and also learn how to properly test my creation before bothering others with it (that would also allow me to fiddle with issue #3).
Do I have to create my own nix-channel for that as a separate repository? How do I add the derivation to my systems configuration.nix? Where should I start reading up on that? I was bit lost between the NixOS wikis, the Nix Pills, the Nix manual and several blog posts.

Sorry for this long post, I know it’s probably all over the place, but I’m happy to clarify things if anything’s unclear. Thank you in advance! :slightly_smiling_face:

Maybe as background: So far I’ve only used NixOS for about 6 months and never written more than my simple configuration and 2-3 mkShell scripts for specific use cases.

Mandrive or so once had a 2K line script to build Eclipse from scratch and that Ecilpse was outdated… The problem is that Eclipse ships it’s own dependency analysis code. So unfortunately it’s best to get any eclipse up and running and just use it’s installer tools.

Patching the binary is just adding some env vars AFAIK. So you can even create a script ‘run-eclipse’ or so. Even copying the eclipse store path somewhere else works if I recall correctly the eclipse from nix store should still be able to install plugins into ~/ something.

You can also look into the solutions for steem runner. Maybe that script just works for you …

/* creates a derivation symlinking references C/C++ libs into one include and lib directory called $out/cdt-envs/${name}
then you can
ln -s ~/.nix-profile/cdt-envs/name ./nix-deps
and add .nix-deps/{libs,includes} to IDE’s such as Eclipse/ Netbeans etc.
To update replace library versions just replace the symlink
cdtEnv = { name, buildInputs }:
stdenv.mkDerivation {
name = “cdt-env-${name}”;
inherit buildInputs;
phases = “installPhase”;
installPhase = ‘’
set -x
# requires bash4

  perlScript=$(dirname $(dirname ${builtins.getEnv "NIXPKGS_ALL"}))/build-support/buildenv/
  # now collect includes and lib paths

  # probably the nix hooks work best, so reuse them by reading NIX_CFLAGS_COMPILE and NIX_LDFLAGS

  PKG_CONFIG_KNOWN_PACKAGES=$(pkg-config --list-all | sed 's/ .*//')

  declare -A INCLUDE_PATHS
  declare -A LIB_PATHS
  declare -A LIBS
  declare -A CFLAGS_OTHER


    echo i is $i
    case $i in
      -I*) INCLUDE_PATHS["''${i/-I/}"]= ;;
      *) CFLAGS_OTHER["''${i}"]= ;;
      echo list is now ''${!INCLUDE_PATHS[@]}

    case $i in
      LIB_PATHS["''${i/-L/}"]= ;;

    echo chekcing $i
    case $i in
      -l*) LIBS["''${i}"]= ;;

  # build output env


    echo "link !!!!"
      echo $1
      echo $2
      export out="$1"
      export paths="$2"

      export ignoreCollisions=1
      export manifest=
      export pathsToLink=/
      ${perl}/bin/perl $perlScript

  mkdir -p $target/{include,lib}
  link $target/lib "$(echo "''${!LIB_PATHS[@]}")"
  link $target/include "$(echo "''${!INCLUDE_PATHS[@]}")"
  echo "''${!LIBS[@]}" > $target/libs
  echo "''${!CFLAGS_OTHER[@]}" > $target/cflags-other
  echo "''${PKG_CONFIG_PATH}" > $target/PKG_CONFIG_PATH
  echo "''${PATH}" > $target/PATH


This is very old code which worked maybe 7 years ago and probably there are better ways to do it now.

I got most of the way through updating Eclipse to 2021-03 a few days ago, but got stuck because the JDT plugin’s stand-alone download seems to have disappeared. :frowning: I’ve just pushed what I have so you can look it over though: Comparing NixOS:master...jerith666:eclipse-2021-03 · NixOS/nixpkgs · GitHub

If Lingua Franca just needed a plugin or two, those are pretty straightforward, but I haven’t seen one of these .setup files before and my guess is it’d be quite an undertaking to convert that beast into a nix expression. So I think I agree with @MarcWeber that your best bet is probably to just add an eclipses.eclipse-dsl to nixpkgs, and then pick up Lingua Franca’s manual install instructions from there.

To get started, you’ll just want to clone nixpkgs, make your edits to its pkgs/applications/editors/eclipse/default.nix file, and then run nixos-rebuild -I nixpkgs=/path/to/your/clone/of/nixpkgs.

Maybe the stop bundling and you should just install plugins yourself today? Don’t know.

Just a quick follow-up that I’ve got an actual formal PR for Eclipse 2021-03 now: