-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PoC: Add cross-compilation support #139
base: master
Are you sure you want to change the base?
Conversation
inherit (nix2container) nix2container; | ||
inherit examples tests; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to move these to legacyPackages
because they're not derivations.
runCommand "image-${baseNameOf name}.json" | ||
{ | ||
inherit imageName meta; | ||
nativeBuildInputs = [ nix2container-bin ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the core change across most derivations. We reference nix2container-bin
through nativeBuildInputs
instead of ${nix2container-bin}/bin/nix2container
. Paired with makeScopeWithSplicing
/callPackage
this automatically resolves to the correct variant of the package.
} | ||
'' | ||
nix2container image \ | ||
--arch ${go.GOARCH} \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We explicitly set the image architecture here to go.GOARCH
. This is the target architecture when cross-compiling.
copyToDockerDaemon = selfBuildHost.copyToDockerDaemon image; | ||
copyToRegistry = selfBuildHost.copyToRegistry image; | ||
copyToPodman = selfBuildHost.copyToPodman image; | ||
copyTo = selfBuildHost.copyTo image; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want these to run on the build platform. These need to be explicitly picked from the buildHost
variant because it's not possible to automatically infer which variant we want here.
I added an alternative implementation that should be easier to review in #153 |
WIP PoC for #138. This is not ready for review, just a starting point. Though all the tests on my machine do seem to pass.
Happy to revert
3.
if you feel this is going too far, but usingcallPackage
in a single file is gonna add a lot of noise and additional indentation.