Nimble lockfile and Nim compiler version interoperability for reproducible builds
0 reputation · 02 Feb 2021, 11:29 UTC
0 reputation · 02 Feb 2021, 11:29 UTC
Goal: ensure that a Nimble lockfile captures the exact Nim compiler version used during dependency resolution so that rebuilding the project on any machine yields bit‑identical binaries.
Currently, Nimble writes package versions and source URLs to nimble.lock but omits the compiler version; the minNimVersion field in nimble.yml only specifies a minimum version, leaving patch‑level changes unrecorded and making builds potentially sensitive to compiler‑specific features or ABI shifts.
The Nim community debates whether extending the lockfile schema to include a compiler version hash would improve reproducibility at the cost of flexibility, and how such a change would affect existing projects that rely on the current lockfile format.
Should Nimble extend the lockfile to store an exact compiler version hash? What trade‑offs arise between guaranteed reproducibility and the ability to use newer, backward‑compatible compiler releases? How would a schema change impact existing lockfiles and downstream tooling?
35275 reputation · 02 Feb 2021, 22:55 UTC
Do not extend nimble.lock with a mandatory compiler hash. An optional, backward-compatible field—or, preferably, an external environment manifest—is the safer path for reproducible Nim builds.
nimble.lock records dependency versions and source URLs, but not the Nim compiler version.minNimVersion in nimble.yml is a lower bound, not a pin.Nim patch releases can alter generated C code or standard-library behavior. Even minor version drift may therefore change the final binary. However, bit-identical output also depends on the C compiler, linker, nimcache paths, and build flags. A compiler hash inside the lockfile is insufficient by itself.
| Approach | Reproducibility | Flexibility | Migration risk |
|---|---|---|---|
| Mandatory compiler hash | High | Low—blocks new patch releases | High—breaks strict parsers |
Optional compilerVersion string | Medium | High | Low—additive change |
| External environment manifest | High (full toolchain) | High | None |
An additive optional field keeps existing lockfiles valid. Strict third-party tooling may reject unknown fields; tolerant parsers or an explicit lockfile format version reduce that risk. A mandatory hash would force every downstream consumer to update.
nimble.lock for dependency resolution only.compilerVersion string rather than a hash.Do you control the C compiler, linker, and build flags in your build environment, or only the Nim version? If the full toolchain is not controlled, compiler pinning in the lockfile will not yield bit-identical binaries regardless of schema changes.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.