Partly to educate myself about Nix and partly thinking maybe it can be useful for a wider public and may be included in nixpkgs at some point, I’m trying to create a derivation for Eclipse with a 3rd-party plugin not currently available in nixpkgs. The plugin is called SASyLF, it implements an educational proof assistant.
I’m heavily basing on pkgs/applications/editors/eclipse
. The plugin I’m interested in provides a JAR that can be put in the dropins
directory – that’s the only supported way. The catch is that the current utilities to get plugins are not ready for a plugin with a single JAR. There are two related utilities in pkgs/applications/editors/eclipse/plugins.nix
:
-
buildEclipsePlugin
– requires two JARs: one with a plugin and one with feature; -
buildEclipseUpdateSite
– requires an “update site” with a plugin
The latter is not applicable at all. The former is almost applicable, I just need to avoid providing the feature JAR. Sidenote: it’s completely legit for an Eclipse plugin to not have a feature, from what I understand. At least, SASyLF manages without one.
So, I copied the code for buildEclipsePlugin
, changed it a bit to accept just the plugin jar and created the following default.nix
:
with import <nixpkgs> {};
rec {
# Helper for the case where we have only plugin JAR.
buildEclipsePluginNoFeature =
{ name, srcPlugin ? null, srcPlugins ? [], ... } @ attrs:
assert srcPlugin == null -> srcPlugins != [];
assert srcPlugin != null -> srcPlugins == [];
let
srcs = if (srcPlugin != null) then [ srcPlugin ] else srcPlugins;
in
eclipses.plugins.buildEclipsePluginBase (attrs // {
buildCommand = ''
dropinDir="$out/eclipse/dropins"
mkdir -p $dropinDir
for plugin in ${toString srcs}; do
cp -v $plugin $dropinDir/$(stripHash $plugin)
done
'';
});
sasylf = buildEclipsePluginNoFeature rec {
pname = "sasylf";
version = "1.5.0";
name = "${pname}-${version}";
srcPlugin = fetchurl {
url = "https://github.com/boyland/sasylf/releases/download/v1.5.0/org.sasylf_1.5.0.v20201210.jar";
sha256 = "1cchhvhi0g2i94x5j8gc1abags6lznzh9n5qhykkm5bv19l0w0i8";
};
};
eclipseSasylf = eclipses.eclipseWithPlugins {
eclipse = eclipses.eclipse-platform;
plugins = [sasylf];
};
}
Unfortunately, when I build it, I get two independent results directories (result
and result-2
): one with the dropins
directory, and one with Eclipse:
$ tree -l
.
├── default.nix
├── result -> /nix/store/ngyb1w90zppxh9nfq1sg67m01scxspkg-eclipse-platform-with-plugins-4.27
│ ├── bin
│ │ └── eclipse
│ ├── etc
│ │ └── eclipse.ini
│ └── share -> /nix/store/vbkzgvz8n5vasb5ljn2l0005g9bzl9hq-eclipse-platform-4.27/share
│ ├── applications
│ │ └── Eclipse.desktop
│ └── pixmaps
│ └── eclipse.xpm -> /nix/store/vbkzgvz8n5vasb5ljn2l0005g9bzl9hq-eclipse-platform-4.27/eclipse/icon.xpm
└── result-2 -> /nix/store/lv44g67izf8pnjdns8w4c5mx14zkn7g3-eclipse-plugin-sasylf-1.5.0
└── eclipse
└── dropins
└── org.sasylf_1.5.0.v20201210.jar
They should all be in one directory! In that case, I think, it will work exactly right. Can someone explain me why I end up with two independent directories?
Other ideas about how to implement it and, possibly, upstream it to nixpkgs, are very welcome!