Skip to content

various: add iOS and iOS simulator cross-compilation#512100

Open
insipx wants to merge 16 commits into
NixOS:stagingfrom
insipx:insipx/ios-build
Open

various: add iOS and iOS simulator cross-compilation#512100
insipx wants to merge 16 commits into
NixOS:stagingfrom
insipx:insipx/ios-build

Conversation

@insipx

@insipx insipx commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

Things done

this is my attempt at iOS cross compilation for nixpkgs. this PR contains some ios-specific changes for packages outside of apple-sdk/compiler-rt as well, since they were required for compiling iOS static/dylib for the project I was testing this with. Happy to split those into separate PRs based on preferences of maintainers here, or if it means getting individual changes in faster.

With this stack i was able to cross compile from aarch64-darwin to x86_64-darwin, iphone64 and iphone64 simulator targets. it bumps gnu-config to a revision which includes ios*-simulator support to make handling -simulator targets more idiomatic

resolves #171537 #361934

  • Built on platform:
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • Tested, as applicable:
  • Ran nixpkgs-review on this PR. See nixpkgs-review usage.
  • Tested basic functionality of all binary files, usually in ./result/bin/.
  • Nixpkgs Release Notes
    • Package update: when the change is major or breaking.
  • NixOS Release Notes
    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.

@insipx
insipx force-pushed the insipx/ios-build branch 4 times, most recently from af88c1b to 586e55b Compare April 21, 2026 14:47
@insipx
insipx changed the base branch from master to staging April 21, 2026 14:53
@nixpkgs-ci nixpkgs-ci Bot closed this Apr 21, 2026
@nixpkgs-ci nixpkgs-ci Bot reopened this Apr 21, 2026
@insipx
insipx force-pushed the insipx/ios-build branch from 586e55b to a7ae3dc Compare April 21, 2026 14:57
@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-linux-stdenv This PR causes stdenv to rebuild on Linux and must target a staging branch. 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild on Darwin and must target a staging branch. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 6.topic: lib The Nixpkgs function library 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related labels Apr 21, 2026
@ofborg ofborg Bot added the 6.topic: cross-compilation Building packages on a different platform than they will be used on label Apr 21, 2026
Comment thread pkgs/by-name/ap/apple-sdk/common/fetch-ios-sdk.nix

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If #511070 is merged, will not using the Apple libiconv on iOS be a problem?

@insipx insipx Apr 21, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIU propagate-common-inputs is using the libiconv built with nix, its the inputs in propagate-inputs that don't work with iOS cross compilation yet (although i'm making good progress getting those working as well).

But, i've tried w/ and w/o libiconv in propagate, and they both work, so i don't see an issue with 511070 either way

I also may misunderstand your question here tho, (or misunderstand the libiconv situation in nixpkgs) so happy to test against realLibiconv pr to verify

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#511070 got dropped. We’re sticking with Apple’s libiconv implementation for now, which should have a fine license.

@insipx
insipx force-pushed the insipx/ios-build branch 2 times, most recently from 0f4875c to 833fdd6 Compare April 24, 2026 13:44

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will send an upstream gnulib patch to upstream this if possible, seems like a no-brainer

@insipx
insipx force-pushed the insipx/ios-build branch from 833fdd6 to f4c2c80 Compare April 24, 2026 13:50
Comment thread lib/systems/examples.nix Outdated
useiOSPrebuilt = true;
darwinSdkVersion = "14";
darwinMinVersion = "14";
xcodeVer = "12";

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unsure if we want to bump this. I tested this stack against xcode 26.3 (that's the one I had installed) and in practice i'm unsure of anyone who wouldn't be on a later xcode version

@insipx
insipx marked this pull request as ready for review April 24, 2026 13:52
@nixpkgs-ci nixpkgs-ci Bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Apr 24, 2026
@insipx
insipx force-pushed the insipx/ios-build branch from f4c2c80 to ad64a01 Compare April 24, 2026 14:02
github-actions[bot]

This comment was marked as outdated.

@github-project-automation github-project-automation Bot moved this to In progress in Nixpkgs Lib Apr 24, 2026
@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. and removed 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-linux-stdenv This PR causes stdenv to rebuild on Linux and must target a staging branch. 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild on Darwin and must target a staging branch. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 10.rebuild-nixos-tests This PR causes rebuilds for all NixOS tests and should normally target the staging branches. 6.topic: lib The Nixpkgs function library 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related labels Jun 9, 2026
@insipx
insipx force-pushed the insipx/ios-build branch 2 times, most recently from ed5b936 to 298f7fe Compare June 10, 2026 18:55
@insipx

insipx commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

just as an update, I updated this PR to the latest staging and am preparing to integrate it (as an additional patch to unstable nixpkgs) into libxmtp iOS dylib/static lib library release flow, so i'll be testing it with a real world app pipeline

insipx added 16 commits July 2, 2026 10:30
Upstream 484648c adds the *-apple-ios-simulator triple, needed by
autotools packages (libiconv, pcre2, gnugrep, sqlcipher).
New simulator ABI with isiOSSimulator predicate; darwinPlatform,
xcodePlatform, and rust target inference; refreshed iphone64 examples.
Extract the iOS SDK from a host Xcode (fetch-ios-sdk.nix), pick the
platform from hostPlatform.xcodePlatform, propagate common inputs on iOS.
iOS defines VOL_CAP_FMT_DECMPFS_COMPRESSION but lacks decmpfs.h
transitive headers; hoist <TargetConditionals.h> above the guard.
Static-only (configure rejects *-apple-ios shared), --with-ospeed=int to
skip the macOS-only <sys/ttydev.h>, no progs/tests (system(3) unavailable).
wipefs/tzbootuuid/tzlink need <sys/disk.h>, <tzfile.h>, or XPC marked
unavailable on iOS; gate on cc.has_header.
Enable COMPILER_RT_ENABLE_IOS without sanitizers; key the DARWIN_*
ARCHS/SYSROOT cmake flags on xcodePlatform (simulator uses iossim).
Substitute @xcodePlatform@ so SDKROOT resolves the right platform SDK
instead of hardcoded MacOSX; export the deployment-target variable.
Pass xcodePlatform and the apple-sdk fallback to the wrapper; export
IPHONEOS_DEPLOYMENT_TARGET for tools invoking the compiler directly.
getentropy is private API on iOS (App Store rejection); strchrnul needs
iOS 18.4+ and only trips -Wunguarded-availability-new.
iOS forbids writable+executable pages (W^X).
gnulib stackvma.c macOS arm includes them unused since 2003; iOS does
not ship them. Two-line deletion, no-op on macOS.
Refresh autosetup config.{sub,guess}, stub system(3) call sites, drop
readline/TCL for cross builds, fix .so vs .dylib install names.
configure rejects shared libs on *-apple-ios; build static-only.
Resolve xcode via targetPackages xcodeVer, fix splices, bake the
deployment target into the clang triple, force wrapped ld via -fuse-ld.
iosSdkPkgs.clang wires the SDK itself; propagating apple-sdk would drag
in the full source-built Darwin bootstrap.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: cross-compilation Building packages on a different platform than they will be used on 6.topic: lib The Nixpkgs function library 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related 6.topic: stdenv Standard environment 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild on Darwin and must target a staging branch. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 10.rebuild-linux-stdenv This PR causes stdenv to rebuild on Linux and must target a staging branch. 10.rebuild-nixos-tests This PR causes rebuilds for all NixOS tests and should normally target the staging branches.

Projects

Status: In progress
Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants