2021-01-25 12:01:06 +11:00
|
|
|
{ lib, makeWrapper, runCommand }: self:
|
2020-10-15 19:05:13 +11:00
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
package:
|
|
|
|
pluginsFun:
|
|
|
|
|
|
|
|
let
|
|
|
|
plugins =
|
|
|
|
if isFunction pluginsFun
|
|
|
|
then pluginsFun self
|
|
|
|
else pluginsFun;
|
|
|
|
|
2020-10-18 17:47:48 +11:00
|
|
|
# FIXME: Is this still needed?
|
2020-10-15 19:05:13 +11:00
|
|
|
info = builtins.parseDrvName package.name;
|
|
|
|
badPlugins = filter (p: ! elem info.name p.jetbrainsPlatforms) plugins;
|
|
|
|
errorMsg = "plugins [ ${toString (map (p: p.name) badPlugins)} ] are not available for platform ${info.name}";
|
|
|
|
in
|
|
|
|
|
|
|
|
assert assertMsg (length badPlugins == 0) errorMsg;
|
|
|
|
|
2021-01-25 12:01:06 +11:00
|
|
|
runCommand
|
|
|
|
(appendToName "with-plugins" package).name
|
|
|
|
{
|
|
|
|
nativeBuildInputs = [ package makeWrapper ];
|
|
|
|
inherit package plugins;
|
|
|
|
packageName = package.name;
|
|
|
|
|
|
|
|
preferLocalBuild = true;
|
|
|
|
allowSubstitutes = false;
|
|
|
|
|
|
|
|
} ''
|
|
|
|
mkdir -p $out/$packageName/plugins
|
|
|
|
for dir in $package/*; do
|
|
|
|
cp -r $dir $out/
|
|
|
|
done
|
|
|
|
|
|
|
|
# Install plugins
|
|
|
|
for plugin in $plugins; do
|
|
|
|
local pluginName=$(basename $plugin)
|
|
|
|
pluginName=''${pluginName#*-}
|
|
|
|
pluginName=''${pluginName%-[0-9.]*}
|
|
|
|
ln -s $plugin $out/$packageName/plugins/$pluginName
|
|
|
|
done
|
|
|
|
|
|
|
|
# Fix up wrapper
|
|
|
|
substituteInPlace $out/bin/* \
|
|
|
|
--replace "$package" "$out"
|
|
|
|
''
|