···11+{ pkgs, ... }:
22+33+# This test builds IDEA Community with some plugins and checks that they can be discovered by the IDE.
44+let
55+ idea = (
66+ pkgs.jetbrains.plugins.addPlugins pkgs.jetbrains.idea-community-src [
77+ # This is a "normal plugin", it's output must be linked into /idea-community/plugins.
88+ "ideavim"
99+ # This is a plugin where the output contains a single JAR file. This JAR file needs to be linked directly in /idea-community/plugins.
1010+ "wakatime"
1111+ ]
1212+ );
1313+in
1414+{
1515+ name = "jetbrains_build-ide-with-plugins";
1616+ meta.maintainers = pkgs.lib.teams.jetbrains.members;
1717+1818+ nodes = {
1919+ server =
2020+ { config, pkgs, ... }:
2121+ {
2222+ environment.systemPackages = [
2323+ idea
2424+ ];
2525+ };
2626+ };
2727+2828+ testScript =
2929+ { ... }:
3030+ ''
3131+ with subtest("ensure normal plugin is available"):
3232+ machine.succeed("find -L ${idea.out}/idea-community/plugins -type f -iname 'IdeaVIM-*.jar' | grep .")
3333+3434+ with subtest("ensure single JAR file plugin is available"):
3535+ machine.succeed("""
3636+ PATH_TO_LINK=$(find ${idea.out}/idea-community/plugins -maxdepth 1 -type l -iname '*wakatime.jar' | grep .)
3737+ test -f $(readlink $PATH_TO_LINK)
3838+ """)
3939+ '';
4040+4141+}
···11-{ jetbrains, writeText }:
11+{
22+ jetbrains,
33+ symlinkJoin,
44+ lib,
55+ # If not set, all IDEs are tested.
66+ ideName ? null,
77+}:
88+99+let
1010+1111+ # Known broken plugins, PLEASE remove entries here whenever possible.
1212+ brokenPlugins = [
1313+ "github-copilot" # GitHub Copilot: https://github.com/NixOS/nixpkgs/issues/400317
1414+ ];
2151616+ ideNames =
1717+ if ideName == null then
1818+ with jetbrains;
1919+ [
2020+ clion
2121+ datagrip
2222+ dataspell
2323+ goland
2424+ idea-community
2525+ idea-ultimate
2626+ mps
2727+ phpstorm
2828+ pycharm-community
2929+ pycharm-professional
3030+ rider
3131+ ruby-mine
3232+ rust-rover
3333+ webstorm
3434+ ]
3535+ else
3636+ [ (jetbrains.${ideName}) ];
3737+in
338{
439 # Check to see if the process for adding plugins is breaking anything, instead of the plugins themselves
55- default =
4040+ empty =
641 let
742 modify-ide = ide: jetbrains.plugins.addPlugins ide [ ];
88- ides =
99- with jetbrains;
1010- map modify-ide [
1111- clion
1212- datagrip
1313- dataspell
1414- goland
1515- idea-community
1616- idea-ultimate
1717- mps
1818- phpstorm
1919- pycharm-community
2020- pycharm-professional
2121- rider
2222- ruby-mine
2323- rust-rover
2424- webstorm
2525- ];
2626- paths = builtins.concatStringsSep " " ides;
2743 in
2828- writeText "jb-ides" paths;
4444+ symlinkJoin {
4545+ name = "jetbrains-test-plugins-empty";
4646+ paths = (map modify-ide ideNames);
4747+ };
29483030- idea-ce-with-plugins = jetbrains.plugins.addPlugins jetbrains.idea-community [
3131- "ideavim"
3232- "nixidea"
3333- # test JAR plugins
3434- "wakatime"
3535- ];
4949+ # Test all plugins. This will only build plugins compatible with the IDE and version. It will fail if the plugin is marked
5050+ # as compatible, but the build version is somehow not in the "builds" map (as that would indicate that something with update_plugins.py went wrong).
5151+ all =
5252+ let
5353+ pluginsJson = builtins.fromJSON (builtins.readFile ./plugins.json);
5454+ pluginsFor =
5555+ with lib.asserts;
5656+ ide:
5757+ builtins.map (plugin: plugin.name) (
5858+ builtins.filter (
5959+ plugin:
6060+ (
6161+ # Plugin has to not be broken
6262+ (!builtins.elem plugin.name brokenPlugins)
6363+ # IDE has to be compatible
6464+ && (builtins.elem ide.pname plugin.compatible)
6565+ # Assert: The build number needs to be included (if marked compatible)
6666+ && (assertMsg (builtins.elem ide.buildNumber (builtins.attrNames plugin.builds)) "For plugin ${plugin.name} no entry for IDE build ${ide.buildNumber} is defined, even though ${ide.pname} is on that build.")
6767+ # The plugin has to exist for the build
6868+ && (plugin.builds.${ide.buildNumber} != null)
6969+ )
7070+ ) (builtins.attrValues pluginsJson.plugins)
7171+ );
7272+ modify-ide = ide: jetbrains.plugins.addPlugins ide (pluginsFor ide);
7373+ in
7474+ symlinkJoin {
7575+ name = "jetbrains-test-plugins-all";
7676+ paths = (map modify-ide ideNames);
7777+ };
3678}
+9-2
pkgs/applications/editors/jetbrains/readme.md
···11This directory contains the build expressions needed to build any of the jetbrains IDEs.
22The jdk is in `pkgs/development/compilers/jetbrains-jdk`.
33-To test the build process of every IDE (as well as the process for adding plugins), build `jetbrains.plugins.tests.default`.
33+44+## Tests:
55+- To test the build process of every IDE (as well as the process for adding plugins), build `jetbrains.plugins.tests.empty`.
66+- To test the build process with all plugins* supported by all IDEs, build `jetbrains.plugins.tests.all`.
77+- To test only plugins for a specific IDE*, build `jetbrains.ide-name.tests.plugins.all`.
88+- To test that plugins are correctly stored in the plugins directory run the NixOS test `nixosTests.jetbrains.plugins-available`.
99+1010+*: Plugins marked as broken in nixpkgs are skipped: When updating/fixing plugins, please check the `brokenPlugins` in `plugins/tests.nix` and update it if needed.
411512## How to use plugins:
613 - Get the ide you want and call `jetbrains.plugins.addPlugins` with a list of plugins you want to add.
714 - The list of plugins can be a list of ids or names (as in `plugins/plugins.json`)
815 - Example: `jetbrains.plugins.addPlugins jetbrains.pycharm-professional [ "nixidea" ]`
99- - The list can also contain a drv giving a `.jar` or `.zip` (this is how you use a plugin not added to nixpkgs)
1616+ - The list can also contain drvs giving the directory contents of the plugin (this is how you use a plugin not added to nixpkgs) or a single `.jar` (executable). For an example, look at the implementation of `fetchPluginSrc` in `plugins/default.nix`.
10171118### How to add a new plugin to nixpkgs
1219 - Find the page for the plugin on https://plugins.jetbrains.com