Is it possible to tell IntelliJ where the jdk is stored?

When installing IntelliJ it cannot find the installed jdk location by default, even when the JAVA_HOME environment variable is set to the correct location within /nix/store.

Does anyone know of a workaround to make it work anyways?
It is a bit annoying to set the jdk location in IntelliJ whenever I update my system packages.

I saw this trick somewhere else and it’s what I use currently. I don’t know if there’s a better alternative:

  environment = {
    systemPackages = with pkgs; [ jdk11_headless ];

    etc = with pkgs; {
      "jdk11".source = jdk11_headless;

This way your JDK will be in /etc/jdk11 and you can point IntelliJ there

I ended up doing something similar, but using home-manager instead.
This is what I did:

    file.".lib/jdk11".source = pkgs.jdk11_headless;