nlewo / nix2container

An archive-less dockerTools.buildImage implementation
Apache License 2.0
501 stars 45 forks source link

PoC: Add cross-compilation support #139

Open szlend opened 2 months ago

szlend commented 2 months ago

WIP PoC for https://github.com/nlewo/nix2container/issues/138. This is not ready for review, just a starting point. Though all the tests on my machine do seem to pass.

  1. Wrap nix2container with makeScopeWithSplicing'. This gives us a way to express different platform variants of our builders/derivations (e.g. buildHost, hostTarget, etc).
  2. Wrap all builders/derivations into the callPackage pattern. This enables package splicing so nativeBuildInputs/buildInputs automatically pick the correct platform variants of our derivations when cross-compiling.
  3. (Optional) Since the callPackage pattern can be pretty noisy, I would suggest extracting individual builders/derivations to their own nix files where it makes sense. Similar to how crane does it here: https://github.com/ipetkov/crane/tree/master/lib

Happy to revert 3. if you feel this is going too far, but using callPackage in a single file is gonna add a lot of noise and additional indentation.