Cross-compile s390x packages from x86_64-linux

This commit is contained in:
Oleks
2026-03-14 00:11:09 +02:00
parent ba535a808e
commit 98f46a8ab7
+72 -28
View File
@@ -22,34 +22,78 @@
"s390x-linux"
];
in
flake-utils.lib.eachSystem supportedSystems (
system:
let
pkgs = import nixpkgs { inherit system; };
in
{
packages = rec {
hello-world = pkgs.callPackage ./packages/hello-world.nix { };
xonsh = pkgs.callPackage ./packages/xonsh.nix { };
default = hello-world;
};
let
# Systems that have native builders
buildSystems = [
"x86_64-linux"
"aarch64-linux"
];
overlays.default = final: prev: {
hello-world = final.callPackage ./packages/hello-world.nix { };
xonsh = final.callPackage ./packages/xonsh.nix { };
};
# Cross-compilation targets from x86_64-linux
crossTargets = {
"s390x-linux" = "s390x-linux";
};
devShells.default = pkgs.mkShell {
name = "oleks-hub-shell";
buildInputs = [ self.packages.${system}.default ];
nativeBuildInputs = with pkgs; [
nix
fmt
];
shellHook = ''
echo "Welcome to the oleks Flake hub development shell."
'';
};
}
);
mkPackages = pkgs: {
hello-world = pkgs.callPackage ./packages/hello-world.nix { };
xonsh = pkgs.callPackage ./packages/xonsh.nix { };
};
# Native builds
native = flake-utils.lib.eachSystem buildSystems (
system:
let
pkgs = import nixpkgs { inherit system; };
packages = mkPackages pkgs;
in
{
packages = packages // {
default = packages.hello-world;
};
overlays.default = final: prev: mkPackages final;
devShells.default = pkgs.mkShell {
name = "oleks-hub-shell";
buildInputs = [ self.packages.${system}.default ];
nativeBuildInputs = with pkgs; [
nix
fmt
];
shellHook = ''
echo "Welcome to the oleks Flake hub development shell."
'';
};
}
);
# Cross-compiled builds (built from x86_64-linux)
cross = builtins.listToAttrs (
builtins.map (
target:
let
pkgs = import nixpkgs {
system = "x86_64-linux";
crossSystem.config = nixpkgs.lib.systems.examples.${
{
"s390x-linux" = "s390x";
}
.${target}
}.config;
};
packages = mkPackages pkgs;
in
{
name = target;
value = packages // {
default = packages.hello-world;
};
}
) (builtins.attrNames crossTargets)
);
in
native
// {
packages = (native.packages or { }) // cross;
};
}