v2 builder: open the cardano-wallet dev shell end-to-end
A cluster of fixes that together let the v2 dev shell evaluate, build,
and reuse prebuilt slices for cardano-wallet on aarch64-darwin. Most
fixes are independent in spirit but interact at the slice level — they
are bundled here to keep the cardano-wallet shell green in a single
commit.
- Sublib reachability env var (`HASKELLNIX_EXTRA_SUBLIB_SEEDS`)
threaded through both the solver-side and install-plan cabal-install
patches. Slices that target a sublib (or transitively depend on
one) seed the patched reachability walk from `pkgLibDepClosure` so
unrelated sublibs (e.g. `lib:testlib`'s deps) stay pruned.
- Source-repository-package handling in slices. Each
`pkg-src.type = "source-repo"` package gets a per-slice minimal git
repo (`git init -b minimal && git add . && git commit`) wrapped
around `${src}` and emitted as a `source-repository-package` block
in the slice's `cabal.project` — the same shape
`lib/call-cabal-project-to-nix.nix` produces at project level — so
cabal hashes the same source bytes plan-nix saw and the slice's
UnitId matches. Build-tools (`alex`, `happy`, `hsc2hs`, ...)
composed via `transitiveBuildToolSlices` so consumers find them in
the cabal-store instead of rebuilding.
- Plan-nix flag honouring for source-repo packages. Module-level
flag overrides (e.g. cardano-wallet's `flags.release = true`) don't
reach cabal at plan time, so plan-nix records cabal-file defaults.
`flagBlockFor` now reads from plan-json for source-repo pkgs so the
slice's `pkgHashFlagAssignment` matches plan-nix.
- Custom-build packages skip the UnitId check. Plan-nix carries a
single shared `id` per Custom-build package; cabal-install splits
them into per-component UnitIds that can never match. Detected via
missing `component-name` on the plan entry.
- `propagatedBuildInputs` for `depSlices` (was `buildInputs`) so
pkg-config deps and other propagated inputs chain transitively
via stdenv. Splice handles the cross-compilation case for normal
nixpkgs deps; slice $outs themselves don't auto-swap but cardano-
wallet's native shell doesn't trip that.
- `cp -rL` for local-package tarballs to inline out-of-bounds
symlinks like cardano-wallet's `lib/wallet/specifications ->
../../specifications` that cabal-install 3.16+ rejects as
[Cabal-7125] "Unsafe link target in tar archive".
- `$out/store` cleanup at end of installPhase. When the expected
UnitId is known, keep only `<uid>/`, `package.db/<uid>.conf` and
`lib/libHS<uid>-*` — `rm -rf $ghcDir` drops everything else
(including the lndir-composed dep symlink tree, which on a deep
graph was 10k+ entries that fixupPhase + NAR serialisation walked
for nothing). Falls back to `find -type l -delete` when the UnitId
isn't known (source-repo or `style: "local"`). Cache files
(`package.cache{,.lock}`) dropped from every slice — stale on
arrival downstream and a major source of "Keeping existing link"
spam at lndir time.
- `find -type d` instead of `ls -d */` for the unitdirs-before
snapshot. bash expands `*/` into args including OS-prefix
unit-ids (`-clsss-1.8.0.1-...`), and `ls` interprets the leading
`-` as flags. Same root cause as the earlier `grep -qx --` fix.
- v2 shell: walk through local packages transitively, collecting
external deps at every step. Local packages are excluded from the
composed cabal-store so cabal compiles them on demand from the
user's tree; their (transitive) external deps go in. Build-tool
exes that resolve to local packages are similarly excluded.
- v2 shell: `pkgs.gitMinimal` on PATH so `git --version` works
inside the shell. On Darwin the apple-sdk overlay sets
`DEVELOPER_DIR` to the SDK path (no tools), so `/usr/bin/git`'s
xcrun shim fails with "tool 'git' not found"; nix-managed git
bypasses the shim.
- Slice cabal: `--jobs=$NIX_BUILD_CORES` (capped at 4, mirrors v1)
on the `cabal v2-build` invocation, which passes through to
`Setup build -jN` for ghc per-module parallelism. Build-phase
flag, so it stays out of `pkgHashConfigureOptions` and UnitIds
remain stable.