Skip to content

Set the build platform on ARM64 hosts - #7

Merged
0xbbuddha merged 1 commit into
TheNullPigeons:mainfrom
whiteov3rflow:fix/arm64-build-platform
Aug 25, 2026
Merged

Set the build platform on ARM64 hosts#7
0xbbuddha merged 1 commit into
TheNullPigeons:mainfrom
whiteov3rflow:fix/arm64-build-platform

Conversation

@whiteov3rflow

Copy link
Copy Markdown
Contributor

Summary

Pass the Nihil image platform to docker build on ARM64 hosts.

The existing pull and container creation paths select linux/amd64 for the currently amd64-only Nihil images. The local build path did not apply the same selection, so nihil build could resolve base images for the ARM64 host architecture instead.

Changes

  • Reuse get_image_platform() in _cmd_build().
  • Add --platform linux/amd64 when building on arm64 or aarch64 hosts.
  • Preserve Docker's default platform selection on amd64 and unknown architectures.
  • Keep the import local to avoid the existing nihil.utils / manager import cycle.
  • Add command-level tests for the full, blueteam, and test build variants.
  • Verify custom tags remain unchanged and no platform flag is added on amd64.

Apple Silicon validation

Validated on macOS ARM64 with OrbStack using nihil build and a minimal source tree based on archlinux:latest:

#2 [internal] load metadata for docker.io/library/archlinux:latest
#4 [1/2] FROM docker.io/library/archlinux:latest@sha256:4bf33b...
[✓] Build complete: nihil/issue6-smoke:local

Resulting image and runtime architectures:

linux/amd64
x86_64

Tests

115 passed in 0.12s

Additional checks:

  • uv pip check
  • git diff --check
  • python -m compileall -q nihil tests
  • Real nihil build smoke test against archlinux:latest

Closes #6.

@0xbbuddha
0xbbuddha self-requested a review August 23, 2026 21:14
0xbbuddha

This comment was marked as low quality.

@0xbbuddha 0xbbuddha left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Perfect, this closes #6 exactly as scoped. Reusing get_image_platform(), keeping the import local, and the ARM validation with the resulting image reporting linux/amd64 are all what I was hoping for. CI is green, I ran the suite locally at 115, and I printed the generated argv to confirm the flag placement, all options land before the build context. Merging.

One nit, worth fixing at some point rather than now: you import from nihil.utils import get_image_platform, while manager.py uses from nihil.utils.platform_info import .... Both work, but it leaves the test suite with two different patch targets, nihil.utils.get_image_platform here and nihil.utils.platform_info.get_image_platform in test_nihilManager.py. If someone later writes a _cmd_build test patching the platform_info path, the patch silently won't apply, the test will run against the real host arch, and it'll pass green on our amd64 CI while testing nothing. Not worth another round trip on this PR, I'll align both on the submodule path in a follow-up commit.

Also noting for the record that your validation used a minimal archlinux:latest tree rather than the full image. That's the right call for verifying the flag, and a complete ARM build of the real image is going to be slow enough under emulation that I wouldn't ask anyone to sit through one. If you ever do run it end to end, we'd genuinely like to know how it goes.

Thanks for your contribution.

@0xbbuddha
0xbbuddha merged commit ee6644e into TheNullPigeons:main Aug 25, 2026
2 checks passed
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.

nihil build fails on ARM64 hosts: docker build is missing --platform

2 participants