pass pkgsCrossStatic to mkOciImage, not pkgsHost
This fixes a bug where the aarch64 OCI image had metadata saying it was an x86_64 OCI image. On top of that, I think the metadata was actually right (aside from Conduit's binary): since all other packages were being pulled from `pkgsHost`, an OCI image cross compiled for aarch64 from a different architecture would result in unexecutable binaries (e.g. tini) since they were compiled for the completely wrong architecture. from: https://gitlab.com/famedly/conduit/-/merge_requests/579 Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
fb1fa4364d
commit
d68268da2e
2 changed files with 40 additions and 26 deletions
|
@ -68,6 +68,9 @@ static:aarch64-unknown-linux-musl:
|
||||||
paths:
|
paths:
|
||||||
- conduit
|
- conduit
|
||||||
|
|
||||||
|
# Note that although we have an `oci-image-x86_64-unknown-linux-musl` output,
|
||||||
|
# we don't build it because it would be largely redundant to this one since it's
|
||||||
|
# all containerized anyway.
|
||||||
oci-image:x86_64-unknown-linux-gnu:
|
oci-image:x86_64-unknown-linux-gnu:
|
||||||
stage: artifacts
|
stage: artifacts
|
||||||
image: nixos/nix:2.19.2
|
image: nixos/nix:2.19.2
|
||||||
|
|
63
flake.nix
63
flake.nix
|
@ -183,34 +183,45 @@
|
||||||
{
|
{
|
||||||
packages = {
|
packages = {
|
||||||
default = package pkgsHost;
|
default = package pkgsHost;
|
||||||
|
|
||||||
oci-image = mkOciImage pkgsHost self.packages.${system}.default;
|
oci-image = mkOciImage pkgsHost self.packages.${system}.default;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
builtins.listToAttrs
|
||||||
|
(builtins.concatLists
|
||||||
|
(builtins.map
|
||||||
|
(crossSystem:
|
||||||
|
let
|
||||||
|
binaryName = "static-${crossSystem}";
|
||||||
|
pkgsCrossStatic =
|
||||||
|
(import nixpkgs {
|
||||||
|
inherit system;
|
||||||
|
crossSystem = {
|
||||||
|
config = crossSystem;
|
||||||
|
};
|
||||||
|
}).pkgsStatic;
|
||||||
|
in
|
||||||
|
[
|
||||||
|
# An output for a statically-linked binary
|
||||||
|
{
|
||||||
|
name = binaryName;
|
||||||
|
value = package pkgsCrossStatic;
|
||||||
|
}
|
||||||
|
|
||||||
# Build an OCI image from the musl aarch64 build so we don't have to
|
# An output for an OCI image based on that binary
|
||||||
# build for aarch64 twice (to make a gnu version specifically for the
|
{
|
||||||
# OCI image)
|
name = "oci-image-${crossSystem}";
|
||||||
oci-image-aarch64-unknown-linux-musl = mkOciImage
|
value = mkOciImage
|
||||||
pkgsHost
|
pkgsCrossStatic
|
||||||
self.packages.${system}.static-aarch64-unknown-linux-musl;
|
self.packages.${system}.${binaryName};
|
||||||
|
}
|
||||||
# Don't build a musl x86_64 OCI image because that would be pointless.
|
]
|
||||||
# Just use the gnu one (i.e. `self.packages."x86_64-linux".oci-image`).
|
)
|
||||||
} // builtins.listToAttrs (
|
[
|
||||||
builtins.map
|
"x86_64-unknown-linux-musl"
|
||||||
(crossSystem: {
|
"aarch64-unknown-linux-musl"
|
||||||
name = "static-${crossSystem}";
|
]
|
||||||
value = package (import nixpkgs {
|
)
|
||||||
inherit system;
|
);
|
||||||
crossSystem = {
|
|
||||||
config = crossSystem;
|
|
||||||
};
|
|
||||||
}).pkgsStatic;
|
|
||||||
})
|
|
||||||
[
|
|
||||||
"x86_64-unknown-linux-musl"
|
|
||||||
"aarch64-unknown-linux-musl"
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
devShells.default = pkgsHost.mkShell {
|
devShells.default = pkgsHost.mkShell {
|
||||||
env = env pkgsHost // {
|
env = env pkgsHost // {
|
||||||
|
|
Loading…
Add table
Reference in a new issue