jetbrains: update IDEA for generated plugins

This commit is contained in:
xeals 2020-10-19 19:11:26 +11:00
parent bb49706b02
commit d851231ee9
Signed by: xeals
GPG Key ID: A498C7AF27EC6B5C
6 changed files with 104 additions and 32 deletions

View File

@ -4,7 +4,7 @@ self:
let let
commonBuild = import ../../../build-support/jetbrains/plugin.nix { commonBuild = import ../../../build-support/jetbrains/plugin-old.nix {
inherit lib stdenv fetchzip; inherit lib stdenv fetchzip;
jetbrainsPlatforms = [ jetbrainsPlatforms = [
"clion" "clion"

View File

@ -1,19 +1,19 @@
{ lib, stdenv, fetchzip }: { lib, stdenv, variant }:
self: self:
let let
ideaBuild = import ../../../build-support/jetbrains/plugin.nix { ideaBuild = import ../../../build-support/jetbrains/plugin.nix {
inherit lib stdenv fetchzip; inherit lib stdenv variant;
jetbrainsPlatforms = [ "idea-community" "idea-ultimate" ]; jetbrainsPlatforms = [ "idea-community" "idea-ultimate" ];
}; };
generateIdea = lib.makeOverridable ({ generateIdea = lib.makeOverridable ({
idea ? ./manual-idea-packages.nix generated ? ./idea-generated.nix
}: let }: let
imported = import idea { imported = import generated {
inherit (self) callPackage; inherit (self) callPackage;
}; };
@ -26,4 +26,3 @@ let
in ideaPlugins // { inherit ideaBuild; }); in ideaPlugins // { inherit ideaBuild; });
in generateIdea { } in generateIdea { }

View File

@ -21,11 +21,13 @@ in
assert assertMsg (length badPlugins == 0) errorMsg; assert assertMsg (length badPlugins == 0) errorMsg;
appendToName "with-plugins" (package.overrideAttrs (oldAttrs: { appendToName "with-plugins" (package.overrideAttrs (oldAttrs: {
passthru = { inherit plugins; }; inherit plugins;
# TODO: Purely aesthetics, but link the plugin to its name instead of hash-name-version # TODO: Remove version from directory name
installPhase = oldAttrs.installPhase + '' installPhase = oldAttrs.installPhase + ''
for plugin in $plugins; do for plugin in $plugins; do
ln -s "$plugin" "$out/$name/plugins/$(basename $plugin)" local dirname=$(basename "$plugin")
dirname=''${dirname:33}
ln -s "$plugin" "$out/$name/plugins/$dirname"
done done
''; '';
})) }))

View File

@ -0,0 +1,33 @@
{ lib
, stdenv
, fetchzip
, jetbrainsPlatforms
}:
{ pluginId
, pname
, version
, versionId
, sha256
, filename ? "${pname}-${version}.zip"
}:
stdenv.mkDerivation {
inherit pname version;
src = fetchzip {
inherit sha256;
url = "https://plugins.jetbrains.com/files/${toString pluginId}/${toString versionId}/${filename}";
};
passthru = { inherit jetbrainsPlatforms; };
installPhase = ''
mkdir $out
cp -r * $out/
'';
meta = {
homepage = "https://plugins.jetbrains.com/plugin/${pluginId}-${lib.toLower pname}";
};
}

View File

@ -1,33 +1,71 @@
{ lib { lib
, stdenv , stdenv
, fetchzip , variant
, jetbrainsPlatforms , jetbrainsPlatforms
}: }:
{ pluginId with lib;
, pname
, version
, versionId
, sha256
, filename ? "${pname}-${version}.zip"
}:
stdenv.mkDerivation { { pname
, version
, plugname
, plugid
, buildInputs ? []
, packageRequires ? []
, meta ? {}
, ...
}@args:
let
defaultMeta = {
broken = false;
platforms = variant.meta.platforms;
} // optionalAttrs ((args.src.meta.homepage or "") != "") {
homepage = args.src.meta.homepage;
} // optionalAttrs ((args.src.meta.description or "") != "") {
description = args.src.meta.description;
};
in
stdenv.mkDerivation ({
inherit pname version; inherit pname version;
src = fetchzip { unpackCmd = ''
inherit sha256; case "$curSrc" in
url = "https://plugins.jetbrains.com/files/${toString pluginId}/${toString versionId}/${filename}"; *.jar)
}; # don't unpack; keep original source filename without the hash
local filename=$(basename "$curSrc")
passthru = { inherit jetbrainsPlatforms; }; filename="''${filename:33}"
cp $curSrc $filename
installPhase = '' chmod +w $filename
mkdir $out sourceRoot="."
cp -r * $out/ ;;
*)
_defaultUnpack "$curSrc"
;;
esac
''; '';
meta = { # FIXME: Entirely possible this isn't correct for niche plugins;
homepage = "https://plugins.jetbrains.com/plugin/${pluginId}-${lib.toLower pname}"; # at the very least there are some plugins that come with JS
}; installPhase = ''
mkdir -p "$out/lib"
find -iname '*.jar' -exec cp {} "$out/lib/" \;
'';
buildInputs = [ ] ++ packageRequires ++ buildInputs;
propagatedBuildInputs = packageRequires;
passthru = { inherit jetbrainsPlatforms plugid plugname; };
doCheck = false;
meta = defaultMeta // meta;
} }
// removeAttrs args [ "buildInputs" "packageRequires" "meta" ])

View File

@ -13,7 +13,7 @@ let
}; };
mkIdeaPlugins = import ../applications/editors/jetbrains/idea-plugins.nix { mkIdeaPlugins = import ../applications/editors/jetbrains/idea-plugins.nix {
inherit lib stdenv fetchzip; inherit lib stdenv variant;
}; };
jetbrainsWithPlugins = import ../applications/editors/jetbrains/wrapper.nix { jetbrainsWithPlugins = import ../applications/editors/jetbrains/wrapper.nix {