No description
  • Nix 71.3%
  • Python 14.7%
  • Shell 10.6%
  • Java 3.3%
Find a file
Stefan Kempinger ea40b81bac
Scala bootstrap: clean up for review (generations, builders, patches/scala)
The frozen per-generation script copies (scala/stages/gen, dgen) are replaced
by one set of builders and named generations:

- scala/chain/scala2.txt and dotty.txt are the chain records; scala2.txt groups
  its stages under `generation NAME` lines.
- nix/scala/generations.nix: a generation is a builder plus its settings;
  one-off workarounds are generations of their own, with their hooks in
  patches/scala/{source,locker,fallback,compiler-first,bridges}.
- scala/builders/{pizza,scala1,nsc0,scala2,dotty}.sh with documented inputs
  and settings (knobs renamed to say what they do); scala/tests, scala/tools.
- nix/scala: default.nix/dotty.nix rewritten, deps.nix (jline, jansi,
  scala-asm, java-diff-utils), builderEnv for building outside Nix,
  scala.all (every stage, dead ends included).
- scala/proto: one env.sh (work directory, Nix inputs, generations) instead
  of hardcoded paths; bisect/pbisect and bridge/pbridge merged.
- tools/scala-chain and tools/dotty-nix read the new records and emit
  nixfmt-formatted Nix.

Checked: every stage builds to the same class files as before (s75-s77
needed LIBRARY_KEEP_FIRST_RUN, version properties only from 2015-03 on), and
`nix build .#scala.all` builds all 315 stages.

Also: nixfmt over all Nix files and the xorg renames in the JDK recipes (no
derivation changes outside Scala), shellcheck fixes, README/NOTES and
scala/README.md updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 22:48:58 +01:00
nix Scala bootstrap: clean up for review (generations, builders, patches/scala) 2026-10-30 22:48:58 +01:00
patches Scala bootstrap: clean up for review (generations, builders, patches/scala) 2026-10-30 22:48:58 +01:00
scala Scala bootstrap: clean up for review (generations, builders, patches/scala) 2026-10-30 22:48:58 +01:00
tools Scala bootstrap: clean up for review (generations, builders, patches/scala) 2026-10-30 22:48:58 +01:00
.gitignore Ant, Java libraries and IntelliJ SDK modules built from source 2026-10-22 00:26:21 +02:00
.shellcheckrc Scala bootstrap: clean up for review (generations, builders, patches/scala) 2026-10-30 22:48:58 +01:00
flake.lock Ant, Java libraries and IntelliJ SDK modules built from source 2026-10-22 00:26:21 +02:00
flake.nix Ant, Java libraries and IntelliJ SDK modules built from source 2026-10-22 00:26:21 +02:00
LICENSE add license file 2026-10-29 12:38:08 +01:00
NOTES.md Scala bootstrap: clean up for review (generations, builders, patches/scala) 2026-10-30 22:48:58 +01:00
README.md Scala bootstrap: clean up for review (generations, builders, patches/scala) 2026-10-30 22:48:58 +01:00

Bootstrapping Gradle, Kotlin, a JDK and Scala from source with Nix

Goal: build recent Gradle, Kotlin and Scala without any prebuilt JDK, Kotlin, Scala, Gradle, IntelliJ or Maven-Central binaries, starting from the (bootstrappable) Nix stdenv.

Layout

Path What
flake.nix pinned nixpkgs, exposes everything as legacyPackages
nix/default.nix the scope tying the stages together (jdk8/jdk11/jdk21 come from nix/jdk; gradleFor instantiates a Gradle version)
nix/jdk/ the JDK chain: jikes → GNU Classpath/JamVM → ecj → IcedTea 7 → OpenJDK 8 … 21 (jdks.openjdkNN); Guix-derived recipes for 9, 10 and 12–20
nix/lib/mk-jar.nix mkJar: compile a source tree with javac into a jar (like Guix' ant-build-system #:jar-name)
nix/lib/fetch-*.nix source fetchers that strip shipped binaries (*.jar, *.class, …)
nix/java/ Ant, ANTLR (2 … tunnelvisionlabs 4.7.4), ICU data, Groovy 3.0.5, protobuf and ~30 third party Java libraries, from source
nix/intellij/ IntelliJ SDK modules (util, core, jps-model, javac2, …) for SDKs 139 … 193, 201+
nix/kotlin/ the Kotlin chain 0.6.786 → 1.1 → 1.2 → 1.3 → … → 2.4.0
nix/gradle/ Gradle 9.8.0 and 8.14.3: ~80 third party libs, Groovy 4.0.33/3.0.24, Kotlin plugins/embeddable jars, every Gradle module compiled directly by javac/kotlinc, distribution assembly
nix/scala/ the Scala chain (2004 Java scalac → 1.x → nsc → 2.13.18, and dotty → 3.10.0)
scala/ the Scala chain records (chain/), stage builders, their tools and tests, and the prototype that found the stages; see scala/README.md
patches/tarcv/ patches from TarCV/kotlin-guix (Apache-2.0)
patches/guix/ patches from Guix for the JDK, ANTLR and Groovy recipes
patches/own/ our patches: IntelliJ SDK ports, Ant runtime targets for Kotlin 1.1.x–1.4
patches/scala/ the hooks of the Scala generations and the scripts of the bridge stages
tools/ hash prefetch/fix helpers, module-graph extraction (gradle-modules, kotlin-modules, intellij-modules), the generators of the Scala chains' Nix files (scala-chain, dotty-nix)

Usage

nix build .#jdks.openjdk21                  # JDK 21, from jikes up
nix build .#kotlin."0.6.786"                # first Kotlin stage, pure Java
nix build .#kotlin."2.4.0"                  # Kotlin 2.4.0 (many stages later)
nix build .#gradleDist                      # Gradle 9.8.0 (= .#gradle."9.8.0".dist)
nix build .#gradle."8.14.3".dist            # Gradle 8.14.3
nix build .#scala.\"2.13.18\"                # Scala 2.13.18, from the 2004 Java scalac
nix build .#scala.\"3.10.0\"                 # Scala 3.10.0 (= .#scala.latest)

Smoke test of the Gradle build: JAVA_HOME=$(nix build --no-link --print-out-paths .#jdks.openjdk21) result/bin/gradle --offline --no-daemon build

Status

See NOTES.md for the detailed log.

  • JDK: built entirely from source. nix/jdk provides OpenJDK 8–21, boot-strapped from jikes + GNU Classpath + JamVM → ecj → IcedTea 7 (nixpkgs' OpenJDK recipe is reused for 8, 11, 17 and 21, fed with our own boot JDK). jdk8, jdk11 and jdk21 in nix/default.nix all point into this chain; no temurin seed is used.
  • Kotlin: 0.6.786 → 2.4.0, every version compiled by the previous one (Ant-based up to 1.2.x, then module-wise kotlinc/javac). Built and smoke-tested up to 2.4.0 (K2 enabled from 2.1.0). Note kotlin.latest is still 1.1.2-5; use kotlin."2.4.0".
  • Gradle: 9.8.0 and 8.14.3 distributions build and run (Groovy and Kotlin DSL java/application builds, offline, --no-daemon). Not done: AWS/GCS/maven modules (resources-s3, resources-gcs, build-init), JNI libraries, and Scala compilation (the Zinc worker is stubbed).
  • Scala: 2.13.18 and 3.10.0. A chain of scala/scala commits (Java scalac of 2004 → Scala 1.x → nsc → 2.x, the first stage translated from Pizza to Java by scala/tools/pizza2java.py), each stage compiled by the previous one, reaches 2.13.18; from 2.12.8 a chain of scala/scala3 commits, each built by the reference compiler it names, reaches 3.10.0. The MSIL backend is stubbed; jline, jansi, scala-asm, zinc's interfaces and the other Java inputs are built from source.
  • Ant, all Java dependencies, IntelliJ SDK modules: built from source.
  • ICU's data (icudata.jar, used by icu4j to generate ANTLR 4's Unicode tables) is rebuilt from the Unicode Character Database text files (nix/java/icu); the prebuilt data in ICU's sources is deleted at fetch time.

Credits

The bootstrap path for Kotlin 1.1.2-5 is the work of Emmanuel Bourg (ebourg/kotlin-bootstrapping), Julien Lepiller (guix-android) and TarCV (kotlin-guix). This repository ports it to Nix.