Skip to content

Bump nix 0.23 -> 0.30 for OpenHarmony (and current libc) compatibility#118

Open
social4hyq wants to merge 1 commit into
elast0ny:masterfrom
social4hyq:nix-030-ohos
Open

Bump nix 0.23 -> 0.30 for OpenHarmony (and current libc) compatibility#118
social4hyq wants to merge 1 commit into
elast0ny:masterfrom
social4hyq:nix-030-ohos

Conversation

@social4hyq
Copy link
Copy Markdown

@social4hyq social4hyq commented Jun 5, 2026

Summary

Bump nix from 0.23 to 0.30 so shared_memory builds under target_env="ohos" (and any other target where nix 0.23 is too old for the current libc).

Why

nix = "0.23" doesn't compile on the OpenHarmony Tier-2 Rust targets (aarch64-unknown-linux-ohos, x86_64-unknown-linux-ohos, etc.). The OHOS port of libc has diverged enough that the 0.23 wrappers no longer type-check; the workspace produces ~50 errors on the first cargo check. nix 0.30 builds cleanly on the same targets and is the current major release.

What changed

  • Cargo.toml: nix = "0.23"nix = { version = "0.30", default-features = false, features = ["fs", "mman"] }. The feature set is minimized to keep the dependency surface tight — shared_memory only uses fs (file descriptor wrappers) and mman (mmap/munmap/shm_open/shm_unlink).
  • src/unix.rs: adapt to the 0.30 API:
    • RawFd arguments that fed into mmap/close now use BorrowedFd<'_> / OwnedFd (via from_raw_fd at the boundary).
    • mmap length argument is now NonZeroUsize.
    • OwnedFd is consumed with into_raw_fd() where we still need a RawFd to return through the public API.

No behavior change; all changes are mechanical updates to match the new type signatures.

Test plan

  • cargo check --target x86_64-unknown-linux-ohos — green
  • cargo check --target aarch64-unknown-linux-ohos — green
  • Downstream fspy (used by voidzero-dev/vite-task) compiles + runs against this branch on OHOS
  • cargo test on existing targets — not yet run locally, would appreciate CI verification

Notes

I'm aware the repo has been quiet for a while (last push Sep 2023). I'm filing this PR + a companion issue (#119) to check on maintenance status. If a co-maintainer or transfer is being considered, happy to help.

This is consumed by voidzero-dev/vite-plus#1766 and voidzero-dev/vite-task#426 for OHOS native build support.

nix 0.23.x does not gate aio_*, lio_listio, FDPIC_FUNCPTRS, UNAME26, __fsword_t, ST_RELATIME, etc. on target_env="ohos", so it fails to compile for *-unknown-linux-ohos targets.

nix 0.30 gates these properly. Adopt the new API surface: shm_open returns OwnedFd (convert via into_raw_fd); ftruncate/fstat/mmap take BorrowedFd (wrap with borrow_raw); mmap takes Option<NonZeroUsize> for size and NonNull for addr; munmap takes NonNull.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant