# Example from my (non public) Software Quality course homework.
# That (private) repo might contain a more up to date version.

{
  pkgs ? import <nixpkgs> {
     # 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