<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<p>Thank you for your report! </p>
<p>I have only touched nix briefly, but it's good to know that they
seem to have an official jdk package. Maybe we should mention this
in the build readme as an alternative way to setup a dev
environment for the JDK?</p>
<p>/Magnus<br>
</p>
<div class="moz-cite-prefix">On 2025-03-07 14:29, Galder Zamarreno
wrote:<br>
</div>
<blockquote type="cite" cite="mid:CAAcPREssgBjNxtDeeD0S_VGFRjRbX_6mFDUEHrLez7FEZYXTFg@mail.gmail.com">
<div dir="ltr">
<div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">Hi,</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><br>
</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">The
dependencies required to build JDK vary depending on which
JDK version you are building. I've been building my own set
of scripts that allows me to easily manage this, to the
extent that I can do it on the given base OS I run. E.g. if
I'm building a mainline I'd use X as boot JDK but if I'm
building a JDK 21 backport I'd use Y as boot JDK. These
scripts are cumbersome and they can't control all tooling
dependencies, so their use is limited.</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><br>
</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">In my
spare time I've been experimenting with Nix, which offers a
declarative way for package management and system
configuration. Its package manager can be installed on
either Linux or Mac and enables you to start shell instances
with a set of isolated dependencies.</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><br>
</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">I've been
wanting to move from my cumbersome scripts to a setup that
allows me to build my local JDKs within a Nix isolated
shell. However, although Nix packages exist that build
OpenJDK [1], these only support Linux and I'm often
developing on a mac. After some exploration, I've been able
to craft a Nix descriptor file that allows me to build JDK
in an isolated Nix shell on a mac. I wanted to share this in
this mailing list in case it is useful to other JDK
developers.</div>
</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><br>
</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">The
starting point is having a mac devkit. Since I'm not a Nix
expert I built it outside of Nix, e.g.</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><br>
</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">```</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">$
cd jdk/make/devkit<br>
$ bash ./createMacosxDevkit.sh /Applications/Xcode.app</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">```</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><br>
</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">Then
I added the devkit manually to the Nix store:</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><br>
</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">```</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">$
cd jdk/build/devkit<br>
$ nix-store --add-fixed --recursive sha256 Xcode16.2-MacOSX15<br>
/nix/store/vhsix1jn849mpxggwbw2zh1nbxpy0grc-Xcode16.2-MacOSX15</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">```</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><br>
</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">Then
I created a shell.nix file that declares the dependencies and
sets environment variables to build the JDK successfully.
Something that is odd is that if you depend on pkgs.jdk23 on
mac, it doesn't throw an error because [1] is not supported
there, but it downloads Azul's Zulu JDK. I've asked how this
happens [2] but didn't get a satisfactory answer but this is
ok for now for a boot jdk. The DEVKIT env variable points to
the devkit I added to the nix store and MIGCC is set so that
the JDK build uses the clang from the package dependency.</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><br>
</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">```</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">{
pkgs ? import <nixpkgs> {} }:<br>
<br>
let<br>
devkit =
"/nix/store/vhsix1jn849mpxggwbw2zh1nbxpy0grc-Xcode16.2-MacOSX15";<br>
in<br>
pkgs.mkShell {<br>
packages = [<br>
pkgs.autoconf<br>
pkgs.jdk23<br>
pkgs.clang<br>
<br>
devkit<br>
];<br>
<br>
shellHook = ''<br>
echo "Setting DEVKIT_ROOT to path of the devkit in the Nix
store."<br>
export DEVKIT_ROOT=${devkit}<br>
<br>
echo "Setting MIGCC to clang compiler cc binary."<br>
export MIGCC="${pkgs.clang}/bin/cc"<br>
'' ;<br>
}</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">```</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><br>
</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">From
the directory where the shell.nix file is located you can
start a Nix shell that will start the isolated environment:</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><br>
</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">```</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">nix-shell</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">```</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><br>
</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">In
that nix-shell you can now configure the JDK pointing the boot
JDK and the devkit:</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><br>
</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">```</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">[nix-shell:
jdk] $ bash configure \<br>
--with-boot-jdk=$(dirname $(dirname $(readlink -f $(which
java)))) \<br>
--with-devkit=$DEVKIT_ROOT<br>
</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">```<br>
<br>
The configure output looks like this:<br>
<br>
```<br>
A new configuration has been successfully created in<br>
/Users/galder/1/colata/nix-darwin/jdk/build/macosx-aarch64-server-release<br>
using configure arguments
'--with-boot-jdk=/nix/store/wm5rma6x2527qmypzj7rwml8vf9vprgj-zulu-ca-jdk-23.0.0/zulu-23.jdk/Contents/Home
--with-devkit=/nix/store/vhsix1jn849mpxggwbw2zh1nbxpy0grc-Xcode16.2-MacOSX15'.<br>
<br>
Configuration summary:<br>
* Name: macosx-aarch64-server-release<br>
* Debug level: release<br>
* HS debug level: product<br>
* JVM variants: server<br>
* JVM features: server: 'cds compiler1 compiler2 dtrace
epsilongc g1gc jfr jni-check jvmci jvmti management parallelgc
serialgc services shenandoahgc vm-structs zgc'<br>
* OpenJDK target: OS: macosx, CPU architecture: aarch64,
address length: 64<br>
* Version string: 25-internal-adhoc.galder.jdk (25-internal)<br>
* Source date: 315532800 (1980-01-01T00:00:00Z)<br>
<br>
Tools summary:<br>
* Boot JDK: openjdk version "23" 2024-09-17 OpenJDK
Runtime Environment Zulu23.28+85-CA (build 23+37) OpenJDK
64-Bit Server VM Zulu23.28+85-CA (build 23+37, mixed mode,
sharing) (at
/nix/store/wm5rma6x2527qmypzj7rwml8vf9vprgj-zulu-ca-jdk-23.0.0/zulu-23.jdk/Contents/Home)<br>
* Toolchain: clang (clang/LLVM from Xcode 16.2)<br>
* Devkit: Xcode 16.2 (devkit)
(/nix/store/vhsix1jn849mpxggwbw2zh1nbxpy0grc-Xcode16.2-MacOSX15)<br>
* C Compiler: Version 16.0.0 (at
/nix/store/vhsix1jn849mpxggwbw2zh1nbxpy0grc-Xcode16.2-MacOSX15/Xcode/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang)<br>
* C++ Compiler: Version 16.0.0 (at
/nix/store/vhsix1jn849mpxggwbw2zh1nbxpy0grc-Xcode16.2-MacOSX15/Xcode/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++)<br>
<br>
Build performance summary:<br>
* Build jobs: 14<br>
* Memory limit: 49152 MB<br>
```</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><br>
</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">Then
you can just run make and verify the JDK version:<br>
<br>
```</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">[nix-shell:
jdk] $ make<br>
...<br>
Finished building target 'default (exploded-image)' in
configuration 'macosx-aarch64-server-release'<br>
<br>
</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">[nix-shell:
jdk] $ ./build/macosx-aarch64-server-release/jdk/bin/java
--version<br>
openjdk 25-internal 2025-09-16<br>
OpenJDK Runtime Environment (build
25-internal-adhoc.galder.jdk)<br>
OpenJDK 64-Bit Server VM (build 25-internal-adhoc.galder.jdk,
mixed mode)<br>
```</div>
<div>
<div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">
<div dir="ltr">
<div>
<div dir="ltr"><br>
</div>
<div dir="ltr">
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">The above
is sufficient for my own use case, but it can be
enhanced further to add capstone dependency...etc.</div>
<br>
</div>
<div dir="ltr">
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">I don't
know who is taking care of [1] but while working on
this a member in Nix macos discord asked me to
create an issue in Nix packages so that others can
maybe take this further and enhance [1] so that it
also supports darwin-aarch64. So I created [3].</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><br>
XCode is tricky to handle, but it would be great if
eventually there would be Nix packages for JDK
devkits for macos. If those were available, it would
enable OpenJDK developers to build earlier JDK
versions even of the very latest macos environments,
by depending on earlier XCode version based JDK
devkits. You could also pick whichever clang,
capstone...etc version that matches that...etc.</div>
</div>
<div dir="ltr"><br>
</div>
<div dir="ltr">
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">Thanks</div>
</div>
<div dir="ltr">Galder</div>
</div>
<div dir="ltr"><br>
</div>
<div dir="ltr">
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">[1] <a href="https://github.com/NixOS/nixpkgs/blob/nixos-24.11/pkgs/development/compilers/openjdk/generic.nix" moz-do-not-send="true" class="moz-txt-link-freetext">https://github.com/NixOS/nixpkgs/blob/nixos-24.11/pkgs/development/compilers/openjdk/generic.nix</a></div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">[2] <a href="https://github.com/NixOS/nixpkgs/issues/377908" moz-do-not-send="true" class="moz-txt-link-freetext">https://github.com/NixOS/nixpkgs/issues/377908</a></div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">[3] <a href="https://github.com/NixOS/nixpkgs/issues/387516" moz-do-not-send="true" class="moz-txt-link-freetext">https://github.com/NixOS/nixpkgs/issues/387516</a></div>
<br>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</body>
</html>