summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Hensing <robert@roberthensing.nl>2024-01-17 13:46:41 +0100
committergithub-actions[bot] <github-actions[bot]@users.noreply.github.com>2024-02-14 22:39:15 +0000
commita96ae5e7e6e092f08977a9b2906e8d7860908c11 (patch)
treeb4bb7a56a73ac0f0791f8cc77bae3f804b215e62
parentnixos/dockerTools: fix includeStorePaths when enableFakechroot (diff)
downloadnixpkgs-a96ae5e7e6e092f08977a9b2906e8d7860908c11.tar.gz
nixosTests.docker-tools: Use both code paths in includeStorePath testorigin/backport-271976-to-release-23.11
(cherry picked from commit 1f9e86f31462b395d77151469a53543a94e46c36)
-rw-r--r--nixos/tests/docker-tools.nix13
-rw-r--r--pkgs/build-support/docker/examples.nix13
2 files changed, 26 insertions, 0 deletions
diff --git a/nixos/tests/docker-tools.nix b/nixos/tests/docker-tools.nix
index 9ff286af4c26..0987e1920b00 100644
--- a/nixos/tests/docker-tools.nix
+++ b/nixos/tests/docker-tools.nix
@@ -71,16 +71,29 @@ in {
docker.succeed("${examples.helloOnRoot} | docker load")
docker.succeed("docker run --rm hello | grep -i hello")
docker.succeed("docker image rm hello:latest")
+
with subtest("includeStorePath = false; breaks example"):
docker.succeed("${examples.helloOnRootNoStore} | docker load")
docker.fail("docker run --rm hello | grep -i hello")
docker.succeed("docker image rm hello:latest")
+ with subtest("includeStorePath = false; breaks example (fakechroot)"):
+ docker.succeed("${examples.helloOnRootNoStoreFakechroot} | docker load")
+ docker.fail("docker run --rm hello | grep -i hello")
+ docker.succeed("docker image rm hello:latest")
+
with subtest("Ensure ZERO paths are added to the store"):
docker.fail("${examples.helloOnRootNoStore} | ${pkgs.crane}/bin/crane export - - | tar t | grep 'nix/store/'")
+ with subtest("Ensure ZERO paths are added to the store (fakechroot)"):
+ docker.fail("${examples.helloOnRootNoStoreFakechroot} | ${pkgs.crane}/bin/crane export - - | tar t | grep 'nix/store/'")
+
with subtest("includeStorePath = false; works with mounted store"):
docker.succeed("${examples.helloOnRootNoStore} | docker load")
docker.succeed("docker run --rm --volume ${builtins.storeDir}:${builtins.storeDir}:ro hello | grep -i hello")
docker.succeed("docker image rm hello:latest")
+ with subtest("includeStorePath = false; works with mounted store (fakechroot)"):
+ docker.succeed("${examples.helloOnRootNoStoreFakechroot} | docker load")
+ docker.succeed("docker run --rm --volume ${builtins.storeDir}:${builtins.storeDir}:ro hello | grep -i hello")
+ docker.succeed("docker image rm hello:latest")
with subtest("Ensure Docker images use a stable date by default"):
docker.succeed(
diff --git a/pkgs/build-support/docker/examples.nix b/pkgs/build-support/docker/examples.nix
index 109bea54ec0c..88f36d337f25 100644
--- a/pkgs/build-support/docker/examples.nix
+++ b/pkgs/build-support/docker/examples.nix
@@ -637,6 +637,19 @@ rec {
];
config.Cmd = [ "hello" ];
includeStorePaths = false;
+ };
+
+ helloOnRootNoStoreFakechroot = pkgs.dockerTools.streamLayeredImage {
+ name = "hello";
+ tag = "latest";
+ contents = [
+ (pkgs.buildEnv {
+ name = "hello-root";
+ paths = [ pkgs.hello ];
+ })
+ ];
+ config.Cmd = [ "hello" ];
+ includeStorePaths = false;
enableFakechroot = true;
};