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}:
8
9# https://download.eclipse.org/eclipse/downloads/ is the main place to
10# find the downloads needed for new versions
11#
12# to test:
13# 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
15let
16 platform_major = "4";
17 platform_minor = "27";
18 year = "2023";
19 month = "03"; #release month
20 buildmonth = "03"; #sometimes differs from release month
21 timestamp = "${year}${buildmonth}020300";
22 gtk = gtk3;
23 arch = if stdenv.hostPlatform.isx86_64 then
24 "x86_64"
25 else if stdenv.hostPlatform.isAarch64 then
26 "aarch64"
27 else throw "don't know what platform suffix for ${stdenv.hostPlatform.system} will be";
28in rec {
29
30 # work around https://bugs.eclipse.org/bugs/show_bug.cgi?id=476075#c3
31 buildEclipseUnversioned = callPackage ./build-eclipse.nix {
32 inherit stdenv makeDesktopItem freetype fontconfig libX11 libXrender zlib
33 jdk glib gtk libXtst gsettings-desktop-schemas webkitgtk
34 makeWrapper;
35 };
36 buildEclipse = eclipseData: buildEclipseUnversioned (eclipseData // { productVersion = "${platform_major}.${platform_minor}"; });
37
38 ### Eclipse CPP
39
40 eclipse-cpp = buildEclipse {
41 name = "eclipse-cpp-${platform_major}.${platform_minor}";
42 description = "Eclipse IDE for C/C++ Developers";
43 src =
44 fetchurl {
45 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";
46 hash = {
47 x86_64 = "sha256-MBng3ETarHMlUUPpVvMIZxVqpe9JW5xNHonnN6CHRcw=";
48 aarch64 = "sha256-7FgpPzp5MY/fB6Q/wvrvi+Lpcm3tmH7bUTLh7q2Rjek=";
49 }.${arch};
50 };
51 };
52
53 ### Eclipse Modeling
54
55 eclipse-modeling = buildEclipse {
56 name = "eclipse-modeling-${platform_major}.${platform_minor}";
57 description = "Eclipse Modeling Tools";
58 src =
59 fetchurl {
60 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";
61 hash = {
62 x86_64 = "sha256-BXofrKElgCG3+WUCanpX1sGLhirj2pLi+pi24Z+WjBk=";
63 aarch64 = "sha256-CdePRa6jmWlt3Wismt3RahGzYOm1ZDwQRt82kRVXSdM=";
64 }.${arch};
65 };
66 };
67
68 ### Eclipse Platform
69
70 eclipse-platform = buildEclipse {
71 name = "eclipse-platform-${platform_major}.${platform_minor}";
72 description = "Eclipse Platform ${year}-${month}";
73 src =
74 fetchurl {
75 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";
76 hash = {
77 x86_64 = "sha256-aprXjNv2NMoIDCNkFxwmMKcGUt2ssRonzTZ/hH57Mig=";
78 aarch64 = "sha256-Aq9PDVo/9zTeQ2j6q5bf1aIKjKM7oonIr1mEQ7rX48Y=";
79 }.${arch};
80 };
81 };
82
83 ### Eclipse Scala SDK
84
85 eclipse-scala-sdk =
86 (buildEclipseUnversioned.override { jdk = jdk8; gtk = gtk2; } {
87 name = "eclipse-scala-sdk-4.7.0";
88 description = "Eclipse IDE for Scala Developers";
89 productVersion = "4.7";
90 src =
91 fetchurl {
92 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";
93 sha256 = "1n5w2a7mh9ajv6fxcas1gpgwb04pdxbr9v5dzr67gsz5bhahq4ya";
94 };
95 }).overrideAttrs(oa: {
96 # Only download for x86_64
97 meta.platforms = [ "x86_64-linux" ];
98 });
99
100 ### Eclipse SDK
101
102 eclipse-sdk = buildEclipse {
103 name = "eclipse-sdk-${platform_major}.${platform_minor}";
104 description = "Eclipse ${year}-${month} Classic";
105 src =
106 fetchurl {
107 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";
108 hash = {
109 x86_64 = "sha256-39DXU7wIsdxkUpNKnYPT7+qPJ2DrF7G7UJqPfhEDGGs=";
110 aarch64 = "sha256-7GwKGNHWPZ3uOFyzQj1dftFFz/3oa2j8XWkRn0wnllY=";
111 }.${arch};
112 };
113 };
114
115 ### Eclipse Java
116
117 eclipse-java = buildEclipse {
118 name = "eclipse-java-${platform_major}.${platform_minor}";
119 description = "Eclipse IDE for Java Developers";
120 src =
121 fetchurl {
122 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";
123 hash = {
124 x86_64 = "sha256-zNBzFHmNaxUutzMh/5pOglJiKh5NAvSVwvPYyA6RVr4=";
125 aarch64 = "sha256-RtLXB9kgpLERfhpvDTaJG84qVyN1Puud1PTZtk/WIO0=";
126 }.${arch};
127 };
128 };
129
130 ### Eclipse Java EE
131
132 eclipse-jee = buildEclipse {
133 name = "eclipse-jee-${platform_major}.${platform_minor}";
134 description = "Eclipse IDE for Enterprise Java and Web Developers";
135 src =
136 fetchurl {
137 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";
138 hash = {
139 x86_64 = "sha256-vpvmKZKVl6ubfq8QMDr0xprXYMWl576hu+ovvREN4ak=";
140 aarch64 = "sha256-5Yqxgl4kkN3Bb7hsTnd9q5TsCpVBVkEVvqPbL5MYEyg=";
141 }.${arch};
142 };
143 };
144
145 ### Eclipse Committers
146
147 eclipse-committers = buildEclipse {
148 name = "eclipse-committers-${platform_major}.${platform_minor}";
149 description = "Eclipse IDE for Eclipse Committers and Eclipse Platform Plugin Developers";
150 src =
151 fetchurl {
152 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";
153 hash = {
154 x86_64 = "sha256-4SAiEZWSUaiK8QO2Hg39FBcj1aYRtbOJkeF1W1AMQBo=";
155 aarch64 = "sha256-+KGDlo6QK3o/n2vSiD0HpIkBwqwIiMXzdFUpfE48gps=";
156 }.${arch};
157 };
158 };
159
160 ### Eclipse IDE for RCP and RAP Developers
161
162 eclipse-rcp = buildEclipse {
163 name = "eclipse-rcp-${platform_major}.${platform_minor}";
164 description = "Eclipse IDE for RCP and RAP Developers";
165 src =
166 fetchurl {
167 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";
168 hash = {
169 x86_64 = "sha256-bhcpzsS9cci3Y3Pk9DOrtPonKjRg/vzDqDr3Be/xfks=";
170 aarch64 = "sha256-YCb4leFWRtx4VPwK/5vgwwDH3/f0/0OWEy4ueAS7sUw=";
171 }.${arch};
172 };
173 };
174
175 ### Environments
176
177 # Function that assembles a complete Eclipse environment from an
178 # Eclipse package and list of Eclipse plugins.
179 eclipseWithPlugins = { eclipse, plugins ? [], jvmArgs ? [] }:
180 let
181 # Gather up the desired plugins.
182 pluginEnv = buildEnv {
183 name = "eclipse-plugins";
184 paths =
185 with lib;
186 filter (x: x ? isEclipsePlugin) (closePropagation plugins);
187 };
188
189 # Prepare the JVM arguments to add to the ini file. We here also
190 # add the property indicating the plugin directory.
191 dropinPropName = "org.eclipse.equinox.p2.reconciler.dropins.directory";
192 dropinProp = "-D${dropinPropName}=${pluginEnv}/eclipse/dropins";
193 jvmArgsText = lib.concatStringsSep "\n" (jvmArgs ++ [dropinProp]);
194
195 # Base the derivation name on the name of the underlying
196 # Eclipse.
197 name = (lib.meta.appendToName "with-plugins" eclipse).name;
198 in
199 runCommand name { nativeBuildInputs = [ makeWrapper ]; } ''
200 mkdir -p $out/bin $out/etc
201
202 # Prepare an eclipse.ini with the plugin directory.
203 cat ${eclipse}/eclipse/eclipse.ini - > $out/etc/eclipse.ini <<EOF
204 ${jvmArgsText}
205 EOF
206
207 makeWrapper ${eclipse}/bin/eclipse $out/bin/eclipse \
208 --add-flags "--launcher.ini $out/etc/eclipse.ini"
209
210 ln -s ${eclipse}/share $out/
211 '';
212
213 ### Plugins
214
215 plugins = callPackage ./plugins.nix { };
216
217}