Merge pull request #292760 from PigeonF/dockertools-build-layered-compressor

dockerTools: Fix changing compression method for `buildLayeredImage`

authored by Robert Hensing and committed by GitHub c740c98f 00f9ac91

+27 -3
+8
nixos/tests/docker-tools.nix
··· 178 "docker load --input='${examples.bashUncompressed}'", 179 "docker rmi ${examples.bashUncompressed.imageName}", 180 ) 181 182 with subtest( 183 "Check if the nix store is correctly initialized by listing "
··· 178 "docker load --input='${examples.bashUncompressed}'", 179 "docker rmi ${examples.bashUncompressed.imageName}", 180 ) 181 + docker.succeed( 182 + "docker load --input='${examples.bashLayeredUncompressed}'", 183 + "docker rmi ${examples.bashLayeredUncompressed.imageName}", 184 + ) 185 + docker.succeed( 186 + "docker load --input='${examples.bashLayeredZstdCompressed}'", 187 + "docker rmi ${examples.bashLayeredZstdCompressed.imageName}", 188 + ) 189 190 with subtest( 191 "Check if the nix store is correctly initialized by listing "
+2 -2
pkgs/build-support/docker/default.nix
··· 517 518 buildLayeredImage = lib.makeOverridable ({ name, compressor ? "gz", ... }@args: 519 let 520 - stream = streamLayeredImage args; 521 compress = compressorForImage compressor name; 522 in 523 runCommand "${baseNameOf name}.tar${compress.ext}" ··· 1287 # Wrapper around streamNixShellImage to build an image from the result 1288 buildNixShellImage = { drv, compressor ? "gz", ... }@args: 1289 let 1290 - stream = streamNixShellImage args; 1291 compress = compressorForImage compressor drv.name; 1292 in 1293 runCommand "${drv.name}-env.tar${compress.ext}"
··· 517 518 buildLayeredImage = lib.makeOverridable ({ name, compressor ? "gz", ... }@args: 519 let 520 + stream = streamLayeredImage (builtins.removeAttrs args ["compressor"]); 521 compress = compressorForImage compressor name; 522 in 523 runCommand "${baseNameOf name}.tar${compress.ext}" ··· 1287 # Wrapper around streamNixShellImage to build an image from the result 1288 buildNixShellImage = { drv, compressor ? "gz", ... }@args: 1289 let 1290 + stream = streamNixShellImage (builtins.removeAttrs args ["compressor"]); 1291 compress = compressorForImage compressor drv.name; 1292 in 1293 runCommand "${drv.name}-env.tar${compress.ext}"
+17 -1
pkgs/build-support/docker/examples.nix
··· 509 contents = pkgs.bashInteractive; 510 }; 511 512 - # buildImage without explicit tag 513 bashNoTagStreamLayered = pkgs.dockerTools.streamLayeredImage { 514 name = "bash-no-tag-stream-layered"; 515 contents = pkgs.bashInteractive;
··· 509 contents = pkgs.bashInteractive; 510 }; 511 512 + # buildLayeredImage without compression 513 + bashLayeredUncompressed = pkgs.dockerTools.buildLayeredImage { 514 + name = "bash-layered-uncompressed"; 515 + tag = "latest"; 516 + compressor = "none"; 517 + contents = pkgs.bashInteractive; 518 + }; 519 + 520 + # buildLayeredImage with zstd compression 521 + bashLayeredZstdCompressed = pkgs.dockerTools.buildLayeredImage { 522 + name = "bash-layered-zstd"; 523 + tag = "latest"; 524 + compressor = "zstd"; 525 + contents = pkgs.bashInteractive; 526 + }; 527 + 528 + # streamLayeredImage without explicit tag 529 bashNoTagStreamLayered = pkgs.dockerTools.streamLayeredImage { 530 name = "bash-no-tag-stream-layered"; 531 contents = pkgs.bashInteractive;