diff --git a/modules/jetbrains-ide.nix b/modules/jetbrains-ide.nix index 1e8dc69..1b92fd7 100644 --- a/modules/jetbrains-ide.nix +++ b/modules/jetbrains-ide.nix @@ -29,12 +29,13 @@ in # /run/current-system/sw/bin/python3 # This makes it easier to configure it as interpreter in Jetbrain's IDE. python3 - # Gradle build tool - gradle - # LTS OpenJDK + + # To use Gradle within InelliJ (or to use a specific OpenJDK version with Gradle), see + # shell-intellij-grade-openjd.nix + + # If a more recent OpenJDK version than the bundled JDK is needed #unstable.jdk - # Latest OpenJDK - unstable.jdk23 + #unstable.jdk23 # Markdown preview #pandoc diff --git a/shell-intellij-gradle-openjdk.nix b/shell-intellij-gradle-openjdk.nix new file mode 100644 index 0000000..3d4b6a2 --- /dev/null +++ b/shell-intellij-gradle-openjdk.nix @@ -0,0 +1,35 @@ +# Example from my (non public) Software Quality course homework. +# That (private) repo might contain a more up to date version. + +{ + pkgs ? import { + # https://github.com/NixOS/nixpkgs/issues/166220#issuecomment-1745803058 + config.allowUnfree = true; + } +}: + +let + unstable = import (fetchTarball https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz) { }; + + # https://github.com/NixOS/nixpkgs/blob/4b218e54ae22c8b3ad642ff0dec842363c3abd0f/pkgs/top-level/all-packages.nix#L14583-L14588 + jdk = unstable.jdk23.override { + enableJavaFX = true; + openjfx_jdk = unstable.openjfx23.override { withWebKit = true; }; + }; + + # https://github.com/NixOS/nixpkgs/blob/23e89b7da85c3640bbc2173fe04f4bd114342367/pkgs/development/tools/build-managers/gradle/default.nix#L46 + gradle = unstable.gradle.override { java = jdk; }; +in + +( + # Gradle's toolchain support does not work with IntelliJ, thus we have to use buildFHSUserEnv + pkgs.buildFHSUserEnv + { + name = "intellij-gradle-jdk23"; + targetPkgs = pkgs_: [ + pkgs_.jetbrains.idea-ultimate + jdk + gradle + ]; + } +).env