nix-git/modules/java.nix

44 lines
1.4 KiB
Nix
Raw Normal View History

2025-01-26 13:24:07 +01:00
{ config, pkgs, lib, ... }:
let
# Select a JDK version
#
jdk = pkgs.jdk23;
#
# If a more recent OpenJDK version than the bundled JDK is needed.
#jdk = pkgs.unstable.jdk;
#jdk = pkgs.unstable.jdk23;
#
# If JavaFX with WebKit is required.
# https://github.com/NixOS/nixpkgs/blob/4b218e54ae22c8b3ad642ff0dec842363c3abd0f/pkgs/top-level/all-packages.nix#L14583-L14588
#jdk = pkgs.jdk23.override {
# enableJavaFX = true;
# openjfx_jdk = pkgs.openjfx23.override { withWebKit = true; };
#};
# https://github.com/NixOS/nixpkgs/blob/23e89b7da85c3640bbc2173fe04f4bd114342367/pkgs/development/tools/build-managers/gradle/default.nix#L46
gradle = pkgs.gradle.override {
java = jdk;
javaToolchains = [ jdk ];
};
in
{
# System-wide installation makes pkgs available at:
# /run/current-system/sw/bin/
# This makes it easier to configure them in Jetbrain's IDE.
environment.systemPackages = with pkgs; [
# To use Gradle in IntelliJ:
# - Project settings > Add and select JDK
# - `type java` gives `/run/current-system/sw/bin/java`.
# - Somehow IntelliJ can't select it
# - Thus we use the symlinks destination instead ...
jdk
# To use Gradle in IntelliJ:
# - Settings > Build tools > Gradle > Local installation
# - `type gradle` gives `/run/current-system/sw/bin/gradle`.
# - Somehow IntelliJ can't select it
# - Thus we use the symlinks destination instead ...
gradle
maven
];
}