From 77037c13d5ca1326816030114216187b29da20f1 Mon Sep 17 00:00:00 2001 From: Daniel Langbein Date: Sat, 23 Nov 2024 16:10:18 +0000 Subject: [PATCH] WIP: shell.nix --- README.md | 13 ++++++++++--- app/build.gradle.kts | 2 +- shell3.nix | 22 ++++++++++++++++++++++ 3 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 shell3.nix diff --git a/README.md b/README.md index 9c9cd83..ee1a784 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,9 @@ Check which Java toolchains can be found by Gradle: ``` - `shell.nix` -> broken (as well for `gradle javaToolchains` -- `shell1.nix` -> works +- `shell1.nix` -> works 🥳 - `shell2.nix` -> broken (as well for `gradle javaToolchains`) +- `shell3.nix` -> works 🥳 This should include version >= 17, e.g.: @@ -30,8 +31,6 @@ This should include version >= 17, e.g.: **IntelliJ** -TODO, nothing has worked so far. - Open issue: gradle's toolchain support does not work with IntelliJ - `shell.nix` @@ -40,6 +39,14 @@ Open issue: gradle's toolchain support does not work with IntelliJ - Instead, we found this: https://discourse.nixos.org/t/overriding-the-jdk-for-gradle-in-a-nix-flake/36541/2 - `shell2.nix` - Another approach - which did no longer work! https://github.com/utybo/Tegral/blob/main/shell.nix +- `shell3.nix` + - This works 🥳 + - STRG ALT SHIFT s -> SDK -> add JDK -> + - home path: /usr/lib/openjdk + - name: usr-lib-jdk + - STRG ALT s -> build tools -> gradle -> + - local installation: /usr/lib/gradle + - Gradle JVM: usr-lib-jdk ### Tasks diff --git a/app/build.gradle.kts b/app/build.gradle.kts index ab822aa..faa7dd0 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -28,7 +28,7 @@ dependencies { // Apply a specific Java toolchain to ease working on different environments. java { toolchain { - languageVersion = JavaLanguageVersion.of(17) + languageVersion = JavaLanguageVersion.of(22) } } diff --git a/shell3.nix b/shell3.nix new file mode 100644 index 0000000..8124ce5 --- /dev/null +++ b/shell3.nix @@ -0,0 +1,22 @@ +# https://discourse.nixos.org/t/how-to-create-a-development-environment-with-intellij-idea-and-openjdk/10153 +{ + pkgs ? import { + # https://github.com/NixOS/nixpkgs/issues/166220#issuecomment-1745803058 + config.allowUnfree = true; + } +}: +( + pkgs.buildFHSUserEnv + { + name = "foo"; + targetPkgs = pkgs: + [ + pkgs.jetbrains.idea-ultimate + + # Gradle 8.7 is configured for JDK 21 + pkgs.jdk + pkgs.gradle + + ]; + } +).env