Skip to content

Commit

Permalink
feat(dev): add plugins support to ide module
Browse files Browse the repository at this point in the history
  • Loading branch information
zakuciael committed Dec 5, 2024
1 parent 82bfd34 commit ab228ea
Show file tree
Hide file tree
Showing 6 changed files with 551 additions and 19 deletions.
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,13 @@
"builtins",
"catppuccin",
"chainloader",
"clion",
"closewindow",
"colour",
"compat",
"concat",
"datagrip",
"dataspell",
"devmon",
"dimaround",
"direnv",
Expand All @@ -71,6 +74,7 @@
"gamemode",
"gamescope",
"Genshin",
"goland",
"grimblast",
"gvfs",
"hypr",
Expand Down Expand Up @@ -107,6 +111,7 @@
"nvme",
"optimise",
"partlabel",
"phpstorm",
"pkgs",
"playerctl",
"pname",
Expand Down Expand Up @@ -134,6 +139,7 @@
"usbhid",
"vesktop",
"vfat",
"vmopts",
"waybar",
"webstorm",
"windowdance",
Expand Down
2 changes: 2 additions & 0 deletions lib/mapper.nix
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ with lib.my.utils; rec {

toJSON = name: attrs: (pkgs.formats.json {}).generate name attrs;

toJavaProperties = name: attrs: (pkgs.formats.javaProperties {}).generate name attrs;

toRasiKeyValue = {indent ? ""}: name: value:
if isRasiSection value
then toRasiSection {inherit indent;} name value # Sections
Expand Down
94 changes: 80 additions & 14 deletions modules/dev/ide.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,98 @@
pkgs,
username,
...
}:
with lib;
with lib.my; let
}: let
inherit (lib) optionalString optionalAttrs concatStringsSep mkOption mkIf types;

cfg = config.modules.dev.ides;
xdg = config.home-manager.users.${username}.xdg;

defaultPlugins = [
"jetbrains-ai-assistant"
"extra-toolwindow-colorful-icons"
"extra-icons"
"direnv-integration"
"-env-files-support"
"-ignore"
"nixidea"
"ideolog"
"just"
"wakatime"
"gittoolbox"
"conventional-commit"
"github-actions-manager"
"discord-rich-presence"
"grazie-pro"
];

mkIDE = pkg: {
plugins ? [],
ignorePlugins ? [],
enableNativeWayland ? true,
extraVmopts ? null,
extraProperties ? null,
}: let
filteredPlugins = builtins.filter (plugin: !builtins.elem plugin ignorePlugins) (defaultPlugins ++ plugins);
in
pkgs.jetbrains.plugins.addPlugins (pkg.override ({
inherit extraProperties;
config_path = "${xdg.configHome}/JetBrains/${pkg.pname}";
caches_path = "${xdg.cacheHome}/JetBrains/${pkg.pname}";
plugins_path = "${xdg.dataHome}/JetBrains/${pkg.pname}";
}
// optionalAttrs (enableNativeWayland || extraVmopts != null) {
vmopts =
(optionalString enableNativeWayland "-Dawt.toolkit.name=WLToolkit ")
+ (optionalString (extraVmopts != null) (concatStringsSep " " extraVmopts));
}))
filteredPlugins;

availableIdes = builtins.listToAttrs (
builtins.map (value: {
name = value.pname;
inherit value;
})
(with pkgs.jetbrains; [
clion
(mkIDE clion {})
datagrip
dataspell
gateway
goland
idea-community
idea-ultimate
(mkIDE goland {
enableNativeWayland = false;
plugins = [
"protocol-buffers"
"ini"
"toml"
];
})
(mkIDE idea-ultimate {
plugins = [
"terraform-and-hcl"
"kubernetes"
"ini"
"toml"
"python"
"python-community-edition"
"php"
"go-template"
"go"
];
})
mps
phpstorm
pycharm-community
pycharm-professional
rider
ruby-mine
rust-rover
webstorm
(mkIDE phpstorm {})
(mkIDE pycharm-professional {})
(mkIDE rider {})
(mkIDE ruby-mine {})
(mkIDE rust-rover {
plugins = [
"protocol-buffers"
"toml"
];
ignorePlugins = [
"jetbrains-ai-assistant"
];
})
(mkIDE webstorm {})
])
);
installedIDEs = builtins.map (name: availableIdes.${name} or availableIdes."${name}-with-plugins") cfg;
Expand Down
70 changes: 68 additions & 2 deletions overlays/jetbrains/ides/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,74 @@ in [
});
};
})
(final: prev: {
(final: prev: let
inherit (lib) optionalString optionalAttrs;
inherit (lib.my.mapper) toJavaProperties;

mkPatchedJetbrainsProductDerivation = name: {
vmopts ? null,
config_path ? null,
caches_path ? null,
plugins_path ? null,
logs_path ? null,
extraProperties ? null,
}: let
pkg =
if !prev.jetbrains ? "${name}"
then throw "JetBrains IDE with name ${name} is not in nixpkgs"
else prev.jetbrains."${name}";
in
(pkg.override {
inherit vmopts;
})
.overrideAttrs (prevAttrs: rec {
ideaPropertiesIDE = pkg.vmoptsIDE;
ideaPropertiesFile =
optionalString
(config_path != null || caches_path != null || plugins_path != null || logs_path != null || extraProperties != null)
(
toJavaProperties "idea.properties" ({}
// optionalAttrs (config_path != null) {"idea.config.path" = config_path;}
// optionalAttrs (caches_path != null) {"idea.system.path" = caches_path;}
// optionalAttrs (plugins_path != null) {"idea.plugins.path" = plugins_path;}
// optionalAttrs (logs_path != null) {"idea.log.path" = logs_path;}
// optionalAttrs (extraProperties != null) extraProperties)
);

installPhase =
builtins.replaceStrings
[''--set-default JDK_HOME "$jdk" \'']
[
''
--set-default ${ideaPropertiesIDE}_PROPERTIES "${ideaPropertiesFile}" \
--set-default JDK_HOME "$jdk" \''
]
prevAttrs.installPhase;
});
ides = [
"clion"
"datagrip"
"dataspell"
"gateway"
"goland"
"idea-community"
"idea-ultimate"
"mps"
"phpstorm"
"pycharm-community"
"pycharm-professional"
"rider"
"ruby-mine"
"rust-rover"
"webstorm"
];
in {
jetbrains =
prev.jetbrains // {};
prev.jetbrains
// (lib.listToAttrs (builtins.map (name: {
inherit name;
value = lib.makeOverridable (mkPatchedJetbrainsProductDerivation name) {};
})
ides));
})
]
6 changes: 3 additions & 3 deletions overlays/jetbrains/plugins/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ in

selectFile = id: ide: build:
if !builtins.elem ide pluginsJson.plugins."${id}".compatible
then throw "Plugin with id ${id} does not support IDE ${ide}"
then throw "Plugin with id ${id} (${pluginsJson.plugins."${id}".name}) does not support IDE ${ide}"
else if !pluginsJson.plugins."${id}".builds ? "${build}"
then throw "Jetbrains IDEs with build ${build} are not in nixpkgs. Try update_plugins.py with --with-build?"
then throw "Jetbrains IDEs with build ${build} (${ide}) are not in nixpkgs. Try update_plugins.py with --with-build?"
else if pluginsJson.plugins."${id}".builds."${build}" == null
then throw "Plugin with id ${id} does not support build ${build}"
then throw "Plugin with id ${id} (${pluginsJson.plugins."${id}".name}) does not support build ${build} (${ide})"
else pluginsJson.plugins."${id}".builds."${build}";

byId =
Expand Down
Loading

0 comments on commit ab228ea

Please sign in to comment.