Installing build toolchain with shell.nix

Hello,

I’m trying to get nix-direnv to load a projects build toolchain when entering the base directory of a Java project, and have a couple of questions/issues. Firstly, my shell.nix currently looks like this:


let
  nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/tarball/nixos-24.05";
  pkgs = import nixpkgs { config = {}; overlays = []; };
in

pkgs.mkShellNoCC {
  packages = with pkgs; [
    temurin-bin-23 maven
  ];
}
  1. This fails with:
       error: undefined variable 'temurin-bin-23'
       at /home/user/javaprj/shell.nix:8:5:
            7|   packages = with pkgs; [
            8|     temurin-bin-23 maven
             |     ^
            9|   ];

…the above works if I use “temurin-bin” without “-23” specifier, installing Java 21 instead. Why is this temurin-bin-23 package failing?

  1. In general, I am surprised that temurin-jdk-bin exists without a version specifier. I installs version 21, but would it not make sense to call it “temurin-jdk-bin-21” so that one can target specific major releases?

nixos-24.05 is long dead, use nixos-24.11 or nixos-unstable.

Indeed, 24.11 fixes this, thank you.

Any advice on the version number for java? I’m assuming that 21 happens to be the default in NixOS 24.11 and everything else has a version qualifier (temurin-bin-17, temurin-bin-23, etc).

I guess this is ok? If the default changes in NixOS 25.05, I would need to change the version when updating the nixpkgs version…