NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.07k stars 14.05k forks source link

Podman: fail to build images for other platforms #222830

Open DCsunset opened 1 year ago

DCsunset commented 1 year ago

Describe the bug

Podman supports building packages for other platforms through build command like:

podman build --platform linux/amd64,linux/arm64 --manifest image-name .

Running this command will result in the following error (suppose sh used in the Dockerfile):

exec container process `/bin/sh`: Exec format error

This is because building images for another platform requires qemu-user-static package as said in the doc, which can't be found in nixpkgs.

Steps To Reproduce

Steps to reproduce the behavior:

  1. Create a Dockerfile to run some command like (apk add nodejs) using alpine image
  2. Run podman build --platform linux/amd64,linux/arm64 --manifest image-name . to build it

Expected behavior

It should build images for multiple platforms successfully.

Notify maintainers

@zowoq @pennae

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.1.19, NixOS, 23.05 (Stoat), 23.05pre463258.7067edc68c0`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.13.3`
 - channels(root): `"nixos, nixos-unstable"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
zowoq commented 1 year ago

Looks like https://github.com/NixOS/nixpkgs/pull/160802 would address this?

DCsunset commented 1 year ago

Yes it seems so. I think the podman module can provide an option to enable qemu-user-static after that PR is merged.