Repository navigation
Tags
Tags
libnix-1.99.0+v2 `cargo --version`: cargo 1.99.0 +libnix v2. Changes since libnix-1.99.0+v1: - Git dependencies come from cargo's own checkout, added to the store as the fetchgit output: no nix-prefetch-git, no second download on every build (#10). fetchgit with submodules is made deterministic on nixpkgs 26.05 (detached git maintenance raced the .git removal). - cargo --version shows the libnix release (LIBNIX_RELEASE, #30): `cargo 1.99.0 +libnix v2`, `libnix: 1.99.0+v2` in `cargo -vV`. - The workspace's path crates share one src, configurable with project_src.include/exclude; the build script run derivations no longer contain an absolute path (a different output directory rebuilt them). - Faster generation and evaluation: cargo_build_caller.nix is evaluated once instead of once per attribute, nix mode skips cargo's legacy fingerprints, the handlebars templates are parsed once, and the lib of a build script run comes from a map (cargo: ~736 -> ~596 ms). - Timings after every build: generation, evaluation, build, other and the total. - build-rs-libnix 0.1.14: the `cargo::` build script syntax (Rust >= 1.77, e.g. blake3's cargo::rustc-cfg) next to `cargo:`. - GC roots: what a build no longer uses is deleted, also the outputs of failed or interrupted builds and what was still in use (the cargo binary that builds its successor), by the next successful build (a file `built` per selection). build-rs-libnix is retained when there are build script runs. tests-libnix/gc/run.sh tests it. Tests: cargo builds itself with CARGO_BACKEND=nix; `cargo test --lib nix_build` passes; test.nix: all 31 projects pass with rustc 1.99.0 (2026-10-27).
libnix-1.87.0+v5 `cargo --version`: cargo 1.87.0 +libnix v5. Changes since libnix-1.87.0+v4: - The toolchain is a pinned rustc 1.87.0 without rust-src (it ended up in the runtime closure of every binary). - build-rs-libnix 0.1.14 from nixcloud/build-rs-libnix (shared with the 1.99 line): cargo:rustc-link-arg (tikv-jemalloc-sys) and the `cargo::` build script syntax next to `cargo:`. The unused crates.io dependency on build-rs-libnix is gone. - Git dependencies come from cargo's own checkout, added to the store as the fetchgit output: no nix-prefetch-git, no second download on every build (#10). fetchgit with submodules is made deterministic on nixpkgs 26.05. - cargo --version shows the libnix release (LIBNIX_RELEASE, #30). - The workspace's path crates share one src, configurable with project_src.include/exclude; the build script run derivations no longer contain an absolute path (fixes the known issue of v4: a different output directory rebuilt them and their dependents). - Large dependency graphs: the library closure of a unit is computed with builtins.genericClosure (the recursion took over 70 minutes for union's ~1700 units). - Faster generation and evaluation: cargo_build_caller.nix is evaluated once instead of once per attribute, no legacy fingerprints, the handlebars templates are parsed once, the lib of a build script run comes from a map. Timings after every build. - GC roots: what a build no longer uses is deleted, also the outputs of failed or interrupted builds and what was still in use (the cargo binary that builds its successor), by the next successful build. build-rs-libnix is retained when there are build script runs. - README: build scripts and build-rs-libnix, commercial support, the link to the 1.99 line. Tests: test.nix: 30 of 31 projects pass with rustc 1.87.0 (union needs a nightly rustc); tests-libnix/gc/run.sh passes.
libnix-1.99.0+v1
The first release of the Rust 1.99.0 line: the libnix patch stack of
libnix-1.87.0+v4, squashed and ported onto upstream's rust-1.99.0
(cargo 0.100.0). `cargo --version`: cargo 1.99.0 +libnix.
Changes since libnix-1.87.0+v4:
- Rust 1.99.0: ported to upstream's new layout (src/cargo/* -> src/*) and
APIs (UserIntent/CompileMode, the removed build plan, FxHash collections,
load_overlaid, a Sync GlobalContext). The generated build system pins
rustc/cargo 1.99.0 from fenix, without rust-src.
- rustc >= 1.90 links with its bundled lld, which bypasses nix's linker
wrapper (no rpath, failing posix_spawnp). The units are built with a
wrapped rustc/rustdoc passing `-C linker-features=-lld`, so they link
through the cc/ld wrapper again.
- Large dependency graphs: the library closure of a unit is computed with
builtins.genericClosure (the recursion was exponential, minutes to hours
of evaluation for ~1500 units), and rustc-linker-arguments-dir reads its
libraries from a file (passAsFile) instead of one argument, which hit
the 128 KiB limit ("Argument list too long").
- build scripts: build-rs-libnix 0.1.12 from nixcloud/build-rs-libnix
(shared with the 1.87 line), with cargo:rustc-link-arg support
(tikv-jemalloc-sys). The unused crates.io dependency on build-rs-libnix
is gone. Not supported yet: the `cargo::` syntax, generic metadata,
rustc-flags and the target-specific rustc-link-arg-* (see README).
- project_root of cargo_build_caller.nix is relative to the actual target
directory (CARGO_TARGET_DIR).
- From the 1.87 line since v4: the toolchain without rust-src, the
commercial support notice.
- Branches: master-libnix is the 1.99 line now (= rust-1.99.0-libnix);
the 1.87 line continues as rust-1.87.0-libnix.
Tests: cargo builds itself with CARGO_BACKEND=nix; `cargo test --lib
nix_build` passes; test.nix: all 31 projects pass with rustc 1.99.0,
among them xai-org/grok-build (~1600 units) and rust-analyzer 2026-10-19
(union was removed, it needs a nightly
8000
rustc).
libnix-1.87.0+v4
Changes since libnix-1.87.0+v3:
- cargo test (unit, integration and doc tests): test harnesses and
examples are built in nix like binaries, from target/<profile>/nix-test
with GC roots of their own, and run on the host like with cargo
(legacy), with the same output. OUT_DIR, rustc-env, CARGO_BIN_EXE_<name>
and the binaries next to integration tests work; doc tests use the
rustdoc and linker the units were built with, so the host needs no
toolchain. env!("CARGO_MANIFEST_DIR") points at the (read-only) sources
in the store.
- cargo run: binaries and examples, with the arguments, exit code,
working directory, OUT_DIR and rustc-env of cargo (legacy).
std::env::current_exe() is the binary in the store.
- cargo install / cargo uninstall: installed binaries stay in the store
(they link against store paths), each rooted by an indirect GC root in
<root>/nix/install/<pkg>-<version>-<hash>/<bin>; <root>/bin links to
them through that root. crates.io packages are fetched into the store
like dependencies. After every install and uninstall, roots no bin/
link uses anymore (uninstalled, replaced by another version) are
removed and their store paths deleted unless something else still uses
them. Crate sources and builds are left to nix-collect-garbage.
- GC roots for everything a build uses (#4): the generated build system
lists every unit output, crate tarball, the toolchain and the external
dependencies; the list is rooted in target/<profile>/nix/gc, so
nix-collect-garbage no longer removes dependency builds. After a build,
what the previous build used and the new one doesn't is deleted through
the nix-daemon, unless something else still uses it ("Removed N unused
store path(s), <size>"). Each selection of root units (cargo build,
cargo run --bin a, cargo test -p x, other features) has a slot of its
own, so building a subset doesn't delete what the full build uses; the
8 most recently built selections are kept.
- cargo clean works in nix mode: removes the target dir (or a profile)
and deletes the store paths its builds rooted, unless used elsewhere;
--dry-run counts them. cargo clean -p and cargo clean gc stay
unsupported.
- Build failures are printed at the end, each under a header naming the
crate and its derivation, instead of interleaved with other builds
(also with --keep-going and after Ctrl-C).
- Git dependencies: fixed a panic for git dependencies outside
~/.cargo/git/checkouts (vendored sources, source replacement), and git
crates are built in a writable copy of their repository instead of the
read-only store (also fixes crates in a subdirectory of their
repository).
- Regression tests (#18): test.nix builds 31 real-world projects at
pinned revisions with the cargo (libnix) of the checkout (IFD) and runs
their binaries; tests-libnix/run.sh builds them one by one with
--keep-going and writes RESULTS.md. 23 pass, the other 8 need a rustc
newer than 1.87.
- flake.nix: cargo-libnix-git-head-via-ifd (the working tree) and
cargo-libnix-git-revision-via-ifd (a pinned revision) build cargo
(libnix) from source via IFD through a shared buildCargoBin { src };
cargo_1_87_vanilla_pin is exported.
- README: supported subcommands and features, how it works,
requirements, a copy-pasteable shell.nix, exporting the build system
for your own project, branches and releases.
Known issue: the absolute path of the generated .nix file leaks into
build script run derivations, so a different output directory (a new
temporary dir of cargo install, the IFD output) rebuilds them and their
dependents.
libnix-1.87.0+v3 Changes since libnix-1.87.0+v2: - Crates come from the Nix store, never from cargo (#24): in nix mode (CARGO_BACKEND=nix) cargo no longer downloads .crate files itself. It asks the nix-daemon to fetch each crates.io crate into the Nix store, all in one request, substituting from a binary cache where possible. These are the same store paths the generated build system's fetchurl uses (crate-<name>-<version>.tar.gz, checksum from Cargo.lock), so every crate is fetched once and shared between cargo and the Nix build. Nothing is written to ~/.cargo/registry/cache; a second run fetches nothing. Without the nix-daemon socket, nix mode stops with a clear error (no fallback to cargo downloads). -v shows the store path on each Downloading line. - Offline builds without the registry index (#22): with --offline/--frozen and a Cargo.lock, nix mode serves crates.io from the store tarballs (unpacked into target/nix-crates-io as a directory source) instead of the crates.io index. So write-nix-buildsystem runs in an IFD sandbox with no network, no registry index and no vendored sources; the crate tarballs only have to be inputs of the derivation. Missing tarballs are listed with their store path and URL. A configured [source.crates-io] replace-with (vendoring) still takes precedence. - flake.nix: the dev shell and flake use the cargo-libnix-1.87.0+v2 release as the default cargo. cargo-libnix-master-via-ifd builds cargo+libnix from source via IFD, with its crate tarballs read from Cargo.lock (builtins.fromTOML + fetchurl) instead of importCargoLock or vendoring, bootstrapped by a vendored stage built with the v2 release. - Safety (#17): a clearer error when a target/nix directory lacks the .cargo-libnix-managed marker, explaining why the marker exists and how to create it.
libnix-1.87.0+v2 Changes since libnix-1.87.0+v1: - nixpkgs and fenix bumped: nixpkgs 26.05 (flake input and the generated cargo_build_caller.nix), fenix updated, toolchain pins fixed in flake.nix. - Parallel builds again (#11): dependency flag files are no longer read with builtins.pathExists/readFile at evaluation time, which forced crates to build one after another; the flags are collected in buildPhase into a rustc response file, so Nix schedules independent crates in parallel. - `cargo --version` reports a " +libnix" suffix. - Builds go over the nix-daemon protocol instead of a `nix build` subprocess: evaluation with nix-instantiate, then one BuildPathsWithResults request, with a structured result per crate and per non-crate dependency. The external logone crate is replaced by an in-tree renderer: Compiling/Building/Downloading lines, rustc diagnostics, failures with their build log, skipped dependents, a status line with correct counts, and the evaluation time. -j and --keep-going are passed to the daemon. Crate tarballs are named like nixpkgs' importCargoLock, so they can come from cache.nixos.org. - IFD support (#22): `cargo build write-nix-buildsystem` needs only --out-dir; without --url/--hash it builds from the local project directory. cargo_build_caller.nix takes `project_root` as an argument, so a build system generated in a derivation can be imported and pointed at the source; it also evaluates in pure (flake) mode. - Better flake.nix support for `nix develop`: PATH is kept when spawning Nix, and the CA certificates, proxies and cache directory for evaluation-time fetches; dev shell fixes; a draft for building cargo from the current checkout via IFD.
libnix: Adding 'nix' as an alternative build backend 'legacy'
flake: fix nix build with more recent generated nix/