git.iko.soy/typeable/nixpkgs
on master help sign in
dockerTools: Test buildLayeredImage with symlinks
ffe5ff6Sarah Brofeldt
nixos/tests/docker-tools.nix+7
@@ -247,5 +247,12 @@ import ./make-test-python.nix ({ pkgs, ... }: {
247 ).strip()
247 ).strip()
248 == "${if pkgs.system == "aarch64-linux" then "amd64" else "arm64"}"
248 == "${if pkgs.system == "aarch64-linux" then "amd64" else "arm64"}"
249 )
249 )
250+
251+ with subtest("buildLayeredImage doesn't dereference /nix/store symlink layers"):
252+ docker.succeed(
253+ "docker load --input='${examples.layeredStoreSymlink}'",
254+ "docker run --rm ${examples.layeredStoreSymlink.imageName} bash -c 'test -L ${examples.layeredStoreSymlink.passthru.symlink}'",
255+ "docker rmi ${examples.layeredStoreSymlink.imageName}",
256+ )
250 '';
257 '';
251})
258})
pkgs/build-support/docker/examples.nix+11
@@ -416,4 +416,15 @@ rec {
416 contents = crossPkgs.hello;
416 contents = crossPkgs.hello;
417 };
417 };
418
418
419+ # layered image where a store path is itself a symlink
420+ layeredStoreSymlink =
421+ let
422+ target = pkgs.writeTextDir "dir/target" "Content doesn't matter.";
423+ symlink = pkgs.runCommandNoCC "symlink" {} "ln -s ${target} $out";
424+ in
425+ pkgs.dockerTools.buildLayeredImage {
426+ name = "layeredstoresymlink";
427+ tag = "latest";
428+ contents = [ pkgs.bash symlink ];
429+ } // { passthru = { inherit symlink; }; };
419}
430}