In nixpkgs-unstable 241313f4 there are only jdk8, 11, 17, 21, 25 packaged. Is there other sources of other versions of jdk packaged?
which openjdk version do you need?
you can search older nixpkgs releases with:
nix-env -f https://github.com/NixOS/nixpkgs/archive/release-16.09.tar.gz -qaP openjdk
just change the release number from 16.09 to somthing older like 15.09
the oldest version i could find was jdk7.
You could use this older version for development with flakes and pinning the nixpkgs-old.url to an older nixpkgs release.
here is a short video that explains the basics: https://www.youtube.com/watch?v=0YBWhSNTgV8
Instead of relying on 10 year old channels with 10 year old CVEs, I’d repackage that old required java version on top of a new nixpkgs, such that you will only have the CVEs of the JDK/JRE and not the CVEs of all of its dependencies.
This repackaging is of course not always possible with a copy and paste of the original expression, but might be much more involved.
I packaged OpenJDK myself so I could have the latest one. Perhaps it’ll work for the version you need.