aboutsummaryrefslogtreecommitdiff
path: root/pkgs/build-support/docker/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/build-support/docker/default.nix')
-rw-r--r--pkgs/build-support/docker/default.nix25
1 files changed, 18 insertions, 7 deletions
diff --git a/pkgs/build-support/docker/default.nix b/pkgs/build-support/docker/default.nix
index ba76ce2b817d..e4e8f794bc4c 100644
--- a/pkgs/build-support/docker/default.nix
+++ b/pkgs/build-support/docker/default.nix
@@ -31,6 +31,7 @@
writeScript,
writeText,
writePython3,
+ system, # Note: This is the cross system we're compiling for
}:
# WARNING: this API is unstable and may be subject to backwards-incompatible changes in the future.
@@ -48,7 +49,7 @@ let
# A user is required by nix
# https://github.com/NixOS/nix/blob/9348f9291e5d9e4ba3c4347ea1b235640f54fd79/src/libutil/util.cc#L478
export USER=nobody
- ${nix}/bin/nix-store --load-db < ${closureInfo {rootPaths = contentsList;}}/registration
+ ${buildPackages.nix}/bin/nix-store --load-db < ${closureInfo {rootPaths = contentsList;}}/registration
mkdir -p nix/var/nix/gcroots/docker/
for i in ${lib.concatStringsSep " " contentsList}; do
@@ -56,6 +57,16 @@ let
done;
'';
+ # Map nixpkgs architecture to Docker notation
+ # Reference: https://github.com/docker-library/official-images#architectures-other-than-amd64
+ getArch = nixSystem: {
+ aarch64-linux = "arm64v8";
+ armv7l-linux = "arm32v7";
+ x86_64-linux = "amd64";
+ powerpc64le-linux = "ppc64le";
+ i686-linux = "i386";
+ }.${nixSystem} or "Can't map Nix system ${nixSystem} to Docker architecture notation. Please check that your input and your requested build are correct or update the mapping in Nixpkgs.";
+
in
rec {
@@ -72,7 +83,7 @@ rec {
, imageDigest
, sha256
, os ? "linux"
- , arch ? buildPackages.go.GOARCH
+ , arch ? getArch system
# This is used to set name to the pulled image
, finalImageName ? imageName
@@ -443,7 +454,7 @@ rec {
runCommand "${name}.tar.gz" {
inherit (stream) imageName;
passthru = { inherit (stream) imageTag; };
- buildInputs = [ pigz ];
+ nativeBuildInputs = [ pigz ];
} "${stream} | pigz -nT > $out";
# 1. extract the base image
@@ -488,7 +499,7 @@ rec {
baseJson = let
pure = writeText "${baseName}-config.json" (builtins.toJSON {
inherit created config;
- architecture = buildPackages.go.GOARCH;
+ architecture = getArch system;
os = "linux";
});
impure = runCommand "${baseName}-config.json"
@@ -715,7 +726,7 @@ rec {
streamScript = writePython3 "stream" {} ./stream_layered_image.py;
baseJson = writeText "${name}-base.json" (builtins.toJSON {
inherit config;
- architecture = buildPackages.go.GOARCH;
+ architecture = getArch system;
os = "linux";
});
@@ -762,7 +773,7 @@ rec {
else
lib.head (lib.strings.splitString "-" (baseNameOf conf.outPath));
paths = referencesByPopularity overallClosure;
- buildInputs = [ jq ];
+ nativeBuildInputs = [ jq ];
} ''
${if (tag == null) then ''
outName="$(basename "$out")"
@@ -826,7 +837,7 @@ rec {
# take images can know in advance how the image is supposed to be used.
isExe = true;
};
- buildInputs = [ makeWrapper ];
+ nativeBuildInputs = [ makeWrapper ];
} ''
makeWrapper ${streamScript} $out --add-flags ${conf}
'';