WIP: shell.nix

This commit is contained in:
Daniel Langbein 2024-11-23 16:10:18 +00:00
parent b8c1b79916
commit 77037c13d5
Signed by: langfingaz
GPG Key ID: 6C47C753F0823002
3 changed files with 33 additions and 4 deletions

View File

@ -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

View File

@ -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)
}
}

22
shell3.nix Normal file
View File

@ -0,0 +1,22 @@
# https://discourse.nixos.org/t/how-to-create-a-development-environment-with-intellij-idea-and-openjdk/10153
{
pkgs ? import <nixpkgs> {
# 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