fix(build-image): Allow "cross-builds" of images for different arch
Imports the package set twice in the builder expression: Once configured for the target system, once configured for the native system. This makes it possible to fetch the actual image contents for the required architecture, but use local tools to assemble the symlink layer and metadata.
This commit is contained in:
parent
d7ccf35149
commit
145b7f4289
1 changed files with 9 additions and 4 deletions
|
@ -45,8 +45,13 @@ let
|
|||
toFile
|
||||
toJSON;
|
||||
|
||||
inherit (pkgs) lib runCommand writeText;
|
||||
# Package set to use for sourcing utilities
|
||||
nativePkgs = import loadPkgs { inherit srcType srcArgs importArgs; };
|
||||
inherit (nativePkgs) coreutils jq openssl lib runCommand writeText symlinkJoin;
|
||||
|
||||
# Package set to use for packages to be included in the image. This
|
||||
# package set is imported with the system set to the target
|
||||
# architecture.
|
||||
pkgs = import loadPkgs {
|
||||
inherit srcType srcArgs;
|
||||
importArgs = importArgs // {
|
||||
|
@ -115,7 +120,7 @@ let
|
|||
runtimeGraph = runCommand "runtime-graph.json" {
|
||||
__structuredAttrs = true;
|
||||
exportReferencesGraph.graph = allContents.contents;
|
||||
PATH = "${pkgs.coreutils}/bin";
|
||||
PATH = "${coreutils}/bin";
|
||||
builder = toFile "builder" ''
|
||||
. .attrs.sh
|
||||
cp .attrs.json ''${outputs[out]}
|
||||
|
@ -124,7 +129,7 @@ let
|
|||
|
||||
# Create a symlink forest into all top-level store paths of the
|
||||
# image contents.
|
||||
contentsEnv = pkgs.symlinkJoin {
|
||||
contentsEnv = symlinkJoin {
|
||||
name = "bulk-layers";
|
||||
paths = allContents.contents;
|
||||
};
|
||||
|
@ -141,7 +146,7 @@ let
|
|||
# Two different hashes are computed for different usages (inclusion
|
||||
# in manifest vs. content-checking in the layer cache).
|
||||
symlinkLayerMeta = fromJSON (readFile (runCommand "symlink-layer-meta.json" {
|
||||
buildInputs = with pkgs; [ coreutils jq openssl ];
|
||||
buildInputs = [ coreutils jq openssl ];
|
||||
}''
|
||||
tarHash=$(sha256sum ${symlinkLayer} | cut -d ' ' -f1)
|
||||
layerSize=$(stat --printf '%s' ${symlinkLayer})
|
||||
|
|
Loading…
Reference in a new issue