Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / applications / editors / eclipse / default.nix
blobb9bd9c0b9634d871c07e5878f405ea64c06526f2
1 { lib, stdenv, fetchurl, makeDesktopItem, makeWrapper
2 , freetype, fontconfig, libX11, libXrender, zlib
3 , glib, gtk3, gtk2, libXtst, jdk, jdk8, gsettings-desktop-schemas
4 , webkitgtk ? null  # for internal web browser
5 , buildEnv, runCommand
6 , callPackage
7 }:
9 # use ./update.sh to help with updating for each quarterly release
11 # then, to test:
12 # for e in cpp modeling platform sdk java jee committers rcp; do for s in pkgs pkgsCross.aarch64-multiplatform; do echo; echo $s $e; nix build -f default.nix ${s}.eclipses.eclipse-${e} -o eclipse-${s}-${e}; done; done
14 let
15   platform_major = "4";
16   platform_minor = "29";
17   year = "2023";
18   month = "09"; #release month
19   buildmonth = "09"; #sometimes differs from release month
20   timestamp = "${year}${buildmonth}031000";
21   gtk = gtk3;
22   arch = if stdenv.hostPlatform.isx86_64 then
23     "x86_64"
24   else if stdenv.hostPlatform.isAarch64 then
25     "aarch64"
26   else throw "don't know what platform suffix for ${stdenv.hostPlatform.system} will be";
27 in rec {
29   # work around https://bugs.eclipse.org/bugs/show_bug.cgi?id=476075#c3
30   buildEclipseUnversioned = callPackage ./build-eclipse.nix {
31     inherit stdenv makeDesktopItem freetype fontconfig libX11 libXrender zlib
32             jdk glib gtk libXtst gsettings-desktop-schemas webkitgtk
33             makeWrapper;
34   };
35   buildEclipse = eclipseData: buildEclipseUnversioned (eclipseData // { productVersion = "${platform_major}.${platform_minor}"; });
37   ### Eclipse CPP
39   eclipse-cpp = buildEclipse {
40     name = "eclipse-cpp-${platform_major}.${platform_minor}";
41     description = "Eclipse IDE for C/C++ Developers";
42     src =
43       fetchurl {
44         url = "https://www.eclipse.org/downloads/download.php?r=1&nf=1&file=/technology/epp/downloads/release/${year}-${month}/R/eclipse-cpp-${year}-${month}-R-linux-gtk-${arch}.tar.gz";
45         hash = {
46           x86_64 = "sha256-r9ZDt1D7Wt0Gp2JvW4Qwkw0Rj8F4IhUiNpVgm8FDdbY=";
47           aarch64 = "sha256-fyIvDY9jQfLwwNL4iaLb80X2eWaYqkLqtMd09yOQGo4=";
48         }.${arch};
49       };
50   };
52   ### Eclipse Modeling
54   eclipse-modeling = buildEclipse {
55     name = "eclipse-modeling-${platform_major}.${platform_minor}";
56     description = "Eclipse Modeling Tools";
57     src =
58       fetchurl {
59         url = "https://www.eclipse.org/downloads/download.php?r=1&nf=1&file=/technology/epp/downloads/release/${year}-${month}/R/eclipse-modeling-${year}-${month}-R-linux-gtk-${arch}.tar.gz";
60         hash = {
61           x86_64 = "sha256-eO+fnoN0jZCURwmy6M0Okb9U4R3z8u1gzfm2mGp+Chc=";
62           aarch64 = "sha256-gN0wu7QOyVslvWum9SIkptADtQoX47UPentEupJBnQ8=";
63         }.${arch};
64       };
65   };
67   ### Eclipse Platform
69   eclipse-platform = buildEclipse {
70     name = "eclipse-platform-${platform_major}.${platform_minor}";
71     description = "Eclipse Platform ${year}-${month}";
72     src =
73       fetchurl {
74         url = "https://www.eclipse.org/downloads/download.php?r=1&nf=1&file=/eclipse/downloads/drops${platform_major}/R-${platform_major}.${platform_minor}-${timestamp}/eclipse-platform-${platform_major}.${platform_minor}-linux-gtk-${arch}.tar.gz";
75         hash = {
76           x86_64 = "sha256-+0yzlB89v8KrhDfo5oqT0NKY/3hPk+Pkp2yGQ0silEg=";
77           aarch64 = "sha256-CvzDldzcmLzL7z9ZRxHQblmvkzza4wQYeDIZf6V6uXk=";
78         }.${arch};
79       };
80   };
82   ### Eclipse Scala SDK
84   eclipse-scala-sdk =
85     (buildEclipseUnversioned.override { jdk = jdk8; gtk = gtk2; } {
86       name = "eclipse-scala-sdk-4.7.0";
87       description = "Eclipse IDE for Scala Developers";
88       productVersion = "4.7";
89       src =
90         fetchurl {
91           url = "https://downloads.typesafe.com/scalaide-pack/4.7.0-vfinal-oxygen-212-20170929/scala-SDK-4.7.0-vfinal-2.12-linux.gtk.x86_64.tar.gz";
92           sha256  = "1n5w2a7mh9ajv6fxcas1gpgwb04pdxbr9v5dzr67gsz5bhahq4ya";
93         };
94   }).overrideAttrs(oa: {
95     # Only download for x86_64
96     meta.platforms = [ "x86_64-linux" ];
97   });
99   ### Eclipse SDK
101   eclipse-sdk = buildEclipse {
102     name = "eclipse-sdk-${platform_major}.${platform_minor}";
103     description = "Eclipse ${year}-${month} Classic";
104     src =
105       fetchurl {
106         url = "https://www.eclipse.org/downloads/download.php?r=1&nf=1&file=/eclipse/downloads/drops${platform_major}/R-${platform_major}.${platform_minor}-${timestamp}/eclipse-SDK-${platform_major}.${platform_minor}-linux-gtk-${arch}.tar.gz";
107         hash = {
108           x86_64 = "sha256-Qp9yKSNWVPH8SX1D4PMfSv3XqiKAQCVXWFcSyQaMFmA=";
109           aarch64 = "sha256-cp8/BiewoNt4txhHmpiBTSXZ2sXXPu6zxuAYi24DF9I=";
110         }.${arch};
111       };
112   };
114   ### Eclipse Java
116   eclipse-java = buildEclipse {
117     name = "eclipse-java-${platform_major}.${platform_minor}";
118     description = "Eclipse IDE for Java Developers";
119     src =
120       fetchurl {
121         url = "https://www.eclipse.org/downloads/download.php?r=1&nf=1&file=/technology/epp/downloads/release/${year}-${month}/R/eclipse-java-${year}-${month}-R-linux-gtk-${arch}.tar.gz";
122         hash = {
123           x86_64 = "sha256-TX8LbbBxRGWJ7lmf3tfK+Eux54dSapCsP7OmLfDw4Do=";
124           aarch64 = "sha256-AltrVmCuSTAoRgVsw98oNiR1HPpbYovz3UNGRXQgiVs=";
125         }.${arch};
126       };
127   };
129   ### Eclipse Java EE
131   eclipse-jee = buildEclipse {
132     name = "eclipse-jee-${platform_major}.${platform_minor}";
133     description = "Eclipse IDE for Enterprise Java and Web Developers";
134     src =
135       fetchurl {
136         url = "https://www.eclipse.org/downloads/download.php?r=1&nf=1&file=/technology/epp/downloads/release/${year}-${month}/R/eclipse-jee-${year}-${month}-R-linux-gtk-${arch}.tar.gz";
137         hash = {
138           x86_64 = "sha256-kMEeY27Q97+5/pbl3of93p43dMXE1NQmuESCsK5sK3g=";
139           aarch64 = "sha256-sf+l/BjJ1VAyrc94oJUKYEInG7wEivbYEhpEXLi4C+w=";
140         }.${arch};
141       };
142   };
144   ### Eclipse Committers
146   eclipse-committers = buildEclipse {
147     name = "eclipse-committers-${platform_major}.${platform_minor}";
148     description = "Eclipse IDE for Eclipse Committers and Eclipse Platform Plugin Developers";
149     src =
150       fetchurl {
151         url = "https://www.eclipse.org/downloads/download.php?r=1&nf=1&file=/technology/epp/downloads/release/${year}-${month}/R/eclipse-committers-${year}-${month}-R-linux-gtk-${arch}.tar.gz";
152         hash = {
153           x86_64 = "sha256-K9+Up4nDXZCBKxzj2LX7F9ioPocHnxPdpHMQuc5oehs=";
154           aarch64 = "sha256-ibB3D+0UuX2c+Cbr0L5r8Rh6BfpmOyXNnSk13m2Q7Zk=";
155         }.${arch};
156       };
157   };
159   ### Eclipse IDE for RCP and RAP Developers
161   eclipse-rcp = buildEclipse {
162     name = "eclipse-rcp-${platform_major}.${platform_minor}";
163     description = "Eclipse IDE for RCP and RAP Developers";
164     src =
165       fetchurl {
166         url = "https://www.eclipse.org/downloads/download.php?r=1&nf=1&file=/technology/epp/downloads/release/${year}-${month}/R/eclipse-rcp-${year}-${month}-R-linux-gtk-${arch}.tar.gz";
167         hash = {
168           x86_64 = "sha256-J+8UbkDiG9F+mDBZwr4HVGJWqeSBGMsl3EIRtA7+fK0=";
169           aarch64 = "sha256-+oYY37fBjEi2GJCZVaCsUyWwAhsPPD6nAstUDGmywwo=";
170         }.${arch};
171       };
172   };
174   ### Environments
176   # Function that assembles a complete Eclipse environment from an
177   # Eclipse package and list of Eclipse plugins.
178   eclipseWithPlugins = { eclipse, plugins ? [], jvmArgs ? [] }:
179     let
180       # Gather up the desired plugins.
181       pluginEnv = buildEnv {
182         name = "eclipse-plugins";
183         paths =
184           with lib;
185             filter (x: x ? isEclipsePlugin) (closePropagation plugins);
186       };
188       # Prepare the JVM arguments to add to the ini file. We here also
189       # add the property indicating the plugin directory.
190       dropinPropName = "org.eclipse.equinox.p2.reconciler.dropins.directory";
191       dropinProp = "-D${dropinPropName}=${pluginEnv}/eclipse/dropins";
192       jvmArgsText = lib.concatStringsSep "\n" (jvmArgs ++ [dropinProp]);
194       # Base the derivation name on the name of the underlying
195       # Eclipse.
196       name = (lib.meta.appendToName "with-plugins" eclipse).name;
197     in
198       runCommand name { nativeBuildInputs = [ makeWrapper ]; } ''
199         mkdir -p $out/bin $out/etc
201         # Prepare an eclipse.ini with the plugin directory.
202         cat ${eclipse}/eclipse/eclipse.ini - > $out/etc/eclipse.ini <<EOF
203         ${jvmArgsText}
204         EOF
206         makeWrapper ${eclipse}/bin/eclipse $out/bin/eclipse \
207           --add-flags "--launcher.ini $out/etc/eclipse.ini"
209         ln -s ${eclipse}/share $out/
210       '';
212   ### Plugins
214   plugins = callPackage ./plugins.nix { };