Use nativeBuildInputs for building Docker images

This commit is contained in:
Kevin Rauwolf 2019-01-29 20:29:18 -08:00
parent f2a1a4e93b
commit 2890a38652

View File

@ -68,7 +68,7 @@ rec {
# We need to sum layer.tar, not a directory, hence tarsum instead of nix-hash. # We need to sum layer.tar, not a directory, hence tarsum instead of nix-hash.
# And we cannot untar it, because then we cannot preserve permissions ecc. # And we cannot untar it, because then we cannot preserve permissions ecc.
tarsum = runCommand "tarsum" { tarsum = runCommand "tarsum" {
buildInputs = [ go ]; nativeBuildInputs = [ go ];
} '' } ''
mkdir tarsum mkdir tarsum
cd tarsum cd tarsum
@ -157,7 +157,7 @@ rec {
}; };
inherit fromImage fromImageName fromImageTag; inherit fromImage fromImageName fromImageTag;
buildInputs = [ utillinux e2fsprogs jshon rsync jq ]; nativeBuildInputs = [ utillinux e2fsprogs jshon rsync jq ];
} '' } ''
rm -rf $out rm -rf $out
@ -282,7 +282,7 @@ rec {
runCommand "${name}-granular-docker-layers" { runCommand "${name}-granular-docker-layers" {
inherit maxLayers; inherit maxLayers;
paths = referencesByPopularity closure; paths = referencesByPopularity closure;
buildInputs = [ jshon rsync tarsum ]; nativeBuildInputs = [ jshon rsync tarsum ];
enableParallelBuilding = true; enableParallelBuilding = true;
} }
'' ''
@ -320,7 +320,7 @@ rec {
uid ? 0, gid ? 0, uid ? 0, gid ? 0,
}: }:
runCommand "${name}-customisation-layer" { runCommand "${name}-customisation-layer" {
buildInputs = [ jshon rsync tarsum ]; nativeBuildInputs = [ jshon rsync tarsum ];
inherit extraCommands; inherit extraCommands;
} }
'' ''
@ -365,7 +365,7 @@ rec {
}: }:
runCommand "docker-layer-${name}" { runCommand "docker-layer-${name}" {
inherit baseJson contents extraCommands; inherit baseJson contents extraCommands;
buildInputs = [ jshon rsync tarsum ]; nativeBuildInputs = [ jshon rsync tarsum ];
} }
'' ''
mkdir layer mkdir layer
@ -520,7 +520,7 @@ rec {
os = "linux"; os = "linux";
}); });
impure = runCommand "${baseName}-standard-dynamic-date.json" impure = runCommand "${baseName}-standard-dynamic-date.json"
{ buildInputs = [ jq ]; } { nativeBuildInputs = [ jq ]; }
'' ''
jq ".created = \"$(TZ=utc date --iso-8601="seconds")\"" ${pure} > $out jq ".created = \"$(TZ=utc date --iso-8601="seconds")\"" ${pure} > $out
''; '';
@ -541,7 +541,7 @@ rec {
inherit uid gid extraCommands; inherit uid gid extraCommands;
}; };
result = runCommand "docker-image-${baseName}.tar.gz" { result = runCommand "docker-image-${baseName}.tar.gz" {
buildInputs = [ jshon pigz coreutils findutils jq ]; nativeBuildInputs = [ jshon pigz coreutils findutils jq ];
# Image name and tag must be lowercase # Image name and tag must be lowercase
imageName = lib.toLower name; imageName = lib.toLower name;
baseJson = configJson; baseJson = configJson;
@ -638,7 +638,7 @@ rec {
os = "linux"; os = "linux";
}); });
impure = runCommand "${baseName}-config.json" impure = runCommand "${baseName}-config.json"
{ buildInputs = [ jq ]; } { nativeBuildInputs = [ jq ]; }
'' ''
jq ".created = \"$(TZ=utc date --iso-8601="seconds")\"" ${pure} > $out jq ".created = \"$(TZ=utc date --iso-8601="seconds")\"" ${pure} > $out
''; '';
@ -656,7 +656,7 @@ rec {
extraCommands; extraCommands;
}; };
result = runCommand "docker-image-${baseName}.tar.gz" { result = runCommand "docker-image-${baseName}.tar.gz" {
buildInputs = [ jshon pigz coreutils findutils jq ]; nativeBuildInputs = [ jshon pigz coreutils findutils jq ];
# Image name and tag must be lowercase # Image name and tag must be lowercase
imageName = lib.toLower name; imageName = lib.toLower name;
imageTag = if tag == null then "" else lib.toLower tag; imageTag = if tag == null then "" else lib.toLower tag;