diff --git a/default.nix b/default.nix index cb89660..09b0ba5 100644 --- a/default.nix +++ b/default.nix @@ -63,38 +63,25 @@ rec { }; # A functional Jetbrains IDE-with-plugins package set. - jetbrains = - let - mkJetbrainsPlugins = import ./pkgs/applications/editors/jetbrains/common-plugins.nix { - inherit (pkgs) callPackage; - }; - mkIdeaPlugins = import ./pkgs/applications/editors/jetbrains/idea-plugins.nix { - inherit (pkgs) callPackage; - }; - - builder = import ./pkgs/applications/editors/jetbrains/builder.nix { - inherit (pkgs) lib; - }; - - jbScope = pkgs.lib.makeScope pkgs.newScope (self: pkgs.lib.makeOverridable - ({ jetbrainsPlugins ? mkJetbrainsPlugins - , ideaPlugins ? mkIdeaPlugins - }: ({ } - // jetbrainsPlugins // { inherit jetbrainsPlugins; } - // ideaPlugins // { inherit ideaPlugins; } - // { - jetbrainsWithPlugins = builder self; - })) - { }); - in - rec { - inherit (jbScope) jetbrainsWithPlugins; - clionWithPlugins = jetbrainsWithPlugins pkgs.jetbrains.clion; - ideaCommunityWithPlugins = jetbrainsWithPlugins pkgs.jetbrains.idea-community; - ideaUltimateWithPlugins = jetbrainsWithPlugins pkgs.jetbrains.idea-ultimate; - plugins = jbScope; + jetbrains = (pkgs.dontRecurseIntoAttrs rec { + jetbrainsPluginsFor = variant: import ./pkgs/top-level/jetbrains-plugins.nix { + inherit (pkgs) lib newScope stdenv fetchzip; + inherit variant; }; + pluginBuild = jetbrainsPlatforms: pkgs.callPackage ./pkgs/build-support/jetbrains/plugin.nix { + inherit jetbrains jetbrainsPlatforms; + }; + + clionPlugins = pkgs.dontRecurseIntoAttrs (jetbrainsPluginsFor pkgs.jetbrains.clion); + ideaCommunityPlugins = pkgs.dontRecurseIntoAttrs (jetbrainsPluginsFor pkgs.jetbrains.idea-community); + ideaUltimatePlugins = pkgs.dontRecurseIntoAttrs (jetbrainsPluginsFor pkgs.jetbrains.idea-ultimate); + + clionWithPlugins = clionPlugins.jetbrainsWithPlugins; + ideaCommunityWithPlugins = ideaCommunityPlugins.jetbrainsWithPlugins; + ideaUltimateWithPlugins = ideaUltimatePlugins.jetbrainsWithPlugins; + }); + libhl = pkgs.callPackage ./pkgs/development/libraries/libhl { }; mopidy-subidy = pkgs.callPackage ./pkgs/applications/audio/mopidy/subidy.nix { diff --git a/pkgs/applications/editors/jetbrains/common-plugins.nix b/pkgs/applications/editors/jetbrains/common-plugins.nix index f6f05f8..734055c 100644 --- a/pkgs/applications/editors/jetbrains/common-plugins.nix +++ b/pkgs/applications/editors/jetbrains/common-plugins.nix @@ -1,6 +1,11 @@ -{ callPackage }: +{ lib, stdenv, fetchzip }: + +self: + let - mkPlugin = callPackage ./build-plugin.nix { + + commonBuild = import ../../../build-support/jetbrains/plugin.nix { + inherit lib stdenv fetchzip; jetbrainsPlatforms = [ "clion" "datagrip" @@ -15,30 +20,22 @@ let "webstorm" ]; }; -in -{ - ideavim = mkPlugin { - pname = "IdeaVim"; - version = "0.57"; - pluginId = 164; - versionId = 85009; - sha256 = "1rwfwj0b0nwi7jxhzxk1r0xc190nf4i3b59i0zknpmgb4yc5clzw"; - }; - checkstyle-idea = mkPlugin { - pname = "CheckStyle-IDEA"; - version = "5.42.0"; - pluginId = 1065; - versionId = 95757; - sha256 = "0sji3649n5zz84dlidqaklipq6vaiafxsvg0gzy3j59mvkz6dk14"; - }; + generateCommon = lib.makeOverridable ({ + common ? ./manual-common-packages.nix + }: let + + imported = import common { + inherit (self) callPackage; + }; + + super = imported; + + overrides = { }; + + jetbrainsPlugins = super // overrides; + + in jetbrainsPlugins // { inherit commonBuild; }); + +in generateCommon { } - google-java-format = mkPlugin rec { - pname = "google-java-format"; - version = "1.7.0.4"; - pluginId = 8527; - versionId = 83164; - sha256 = "1pmnn1ksiv44kdga53gi3psrm2sva4bqrxizagbr0if2n0rrvgii"; - filename = "${pname}.zip"; - }; -} diff --git a/pkgs/applications/editors/jetbrains/idea-plugins.nix b/pkgs/applications/editors/jetbrains/idea-plugins.nix index a29616c..33188ec 100644 --- a/pkgs/applications/editors/jetbrains/idea-plugins.nix +++ b/pkgs/applications/editors/jetbrains/idea-plugins.nix @@ -1,15 +1,29 @@ -{ callPackage }: +{ lib, stdenv, fetchzip }: + +self: + let - mkPlugin = callPackage ./build-plugin.nix { + + ideaBuild = import ../../../build-support/jetbrains/plugin.nix { + inherit lib stdenv fetchzip; jetbrainsPlatforms = [ "idea-community" "idea-ultimate" ]; }; -in -{ - spring-assistant = mkPlugin { - pname = "intellij-spring-assistant"; - version = "0.12.0"; - pluginId = 10229; - versionId = 44968; - sha256 = "13cglywzhb4j0qj0bs2jwaz2k8pxrxalv35wgkmgkxr635bxmwsj"; - }; -} + + generateIdea = lib.makeOverridable ({ + idea ? ./manual-idea-packages.nix + }: let + + imported = import idea { + inherit (self) callPackage; + }; + + super = imported; + + overrides = { }; + + ideaPlugins = super // overrides; + + in ideaPlugins // { inherit ideaBuild; }); + +in generateIdea { } + diff --git a/pkgs/applications/editors/jetbrains/manual-common-packages.nix b/pkgs/applications/editors/jetbrains/manual-common-packages.nix new file mode 100644 index 0000000..8020aa8 --- /dev/null +++ b/pkgs/applications/editors/jetbrains/manual-common-packages.nix @@ -0,0 +1,33 @@ +{ callPackage }: +{ + ideavim = callPackage + ({ commonBuild }: commonBuild { + pname = "IdeaVim"; + version = "0.57"; + pluginId = 164; + versionId = 85009; + sha256 = "1rwfwj0b0nwi7jxhzxk1r0xc190nf4i3b59i0zknpmgb4yc5clzw"; + }) + { }; + + checkstyle-idea = callPackage + ({ commonBuild }: commonBuild { + pname = "CheckStyle-IDEA"; + version = "5.42.0"; + pluginId = 1065; + versionId = 95757; + sha256 = "0sji3649n5zz84dlidqaklipq6vaiafxsvg0gzy3j59mvkz6dk14"; + }) + { }; + + google-java-format = callPackage + ({ commonBuild }: commonBuild rec { + pname = "google-java-format"; + version = "1.7.0.4"; + pluginId = 8527; + versionId = 83164; + sha256 = "1pmnn1ksiv44kdga53gi3psrm2sva4bqrxizagbr0if2n0rrvgii"; + filename = "${pname}.zip"; + }) + { }; +} diff --git a/pkgs/applications/editors/jetbrains/manual-idea-packages.nix b/pkgs/applications/editors/jetbrains/manual-idea-packages.nix new file mode 100644 index 0000000..4161319 --- /dev/null +++ b/pkgs/applications/editors/jetbrains/manual-idea-packages.nix @@ -0,0 +1,12 @@ +{ callPackage }: +{ + spring-assistant = callPackage + ({ ideaBuild }: ideaBuild { + pname = "intellij-spring-assistant"; + version = "0.12.0"; + pluginId = 10229; + versionId = 44968; + sha256 = "13cglywzhb4j0qj0bs2jwaz2k8pxrxalv35wgkmgkxr635bxmwsj"; + }) + { }; +} diff --git a/pkgs/applications/editors/jetbrains/builder.nix b/pkgs/applications/editors/jetbrains/wrapper.nix similarity index 80% rename from pkgs/applications/editors/jetbrains/builder.nix rename to pkgs/applications/editors/jetbrains/wrapper.nix index 6ceb418..7ce5be7 100644 --- a/pkgs/applications/editors/jetbrains/builder.nix +++ b/pkgs/applications/editors/jetbrains/wrapper.nix @@ -12,22 +12,19 @@ let then pluginsFun self else pluginsFun; + # FIXME: Is this still needed? 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; -package.overrideAttrs (oldAttrs: { - # FIXME: versioning: could just expose upstream - name = "${info.name}-with-plugins-${info.version}"; - +appendToName "with-plugins" (package.overrideAttrs (oldAttrs: { inherit plugins; installPhase = oldAttrs.installPhase + '' for plugin in $plugins; do ln -s "$plugin" "$out/$name/plugins/$(basename $plugin)" done ''; -}) +})) diff --git a/pkgs/applications/editors/jetbrains/build-plugin.nix b/pkgs/build-support/jetbrains/plugin.nix similarity index 79% rename from pkgs/applications/editors/jetbrains/build-plugin.nix rename to pkgs/build-support/jetbrains/plugin.nix index 171b774..82f8ff5 100644 --- a/pkgs/applications/editors/jetbrains/build-plugin.nix +++ b/pkgs/build-support/jetbrains/plugin.nix @@ -1,4 +1,5 @@ -{ stdenv +{ lib +, stdenv , fetchzip , jetbrainsPlatforms }: @@ -12,19 +13,21 @@ }: stdenv.mkDerivation { - inherit pname version jetbrainsPlatforms; + 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}-${stdenv.lib.toLower pname}"; + homepage = "https://plugins.jetbrains.com/plugin/${pluginId}-${lib.toLower pname}"; }; } diff --git a/pkgs/top-level/jetbrains-plugins.nix b/pkgs/top-level/jetbrains-plugins.nix new file mode 100644 index 0000000..badfac5 --- /dev/null +++ b/pkgs/top-level/jetbrains-plugins.nix @@ -0,0 +1,33 @@ +{ lib +, newScope +, stdenv +, fetchzip + +, variant +}: + +let + + mkJetbrainsPlugins = import ../applications/editors/jetbrains/common-plugins.nix { + inherit lib stdenv fetchzip; + }; + + mkIdeaPlugins = import ../applications/editors/jetbrains/idea-plugins.nix { + inherit lib stdenv fetchzip; + }; + + jetbrainsWithPlugins = import ../applications/editors/jetbrains/wrapper.nix { + inherit lib; + }; + +in lib.makeScope newScope (self: lib.makeOverridable ({ + jetbrainsPlugins ? mkJetbrainsPlugins self + , ideaPlugins ? mkIdeaPlugins self +}: ({ } + // jetbrainsPlugins // { inherit jetbrainsPlugins; } + // ideaPlugins // { inherit ideaPlugins; } + // { + inherit variant; + jetbrainsWithPlugins = jetbrainsWithPlugins self variant; + }) +) { })