From 60737bd31985116b7cce47f221e8568e66ab73e0 Mon Sep 17 00:00:00 2001 From: Samuel Dionne-Riel Date: Tue, 22 May 2018 19:53:28 -0400 Subject: [PATCH] dockerTools: fixes extraCommands for mkRootLayer. The extraCommands was, previously, simply put in the body of the script using nix expansion `${extraCommands}` (which looks exactly like bash expansion!). This causes issues like in #34779 where scripts will eventually create invalid bash. The solution is to use a script like `run-as-root`. * * * Fixes #34779 --- pkgs/build-support/docker/default.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkgs/build-support/docker/default.nix b/pkgs/build-support/docker/default.nix index 374b71d42a39..34af6ad65b9f 100644 --- a/pkgs/build-support/docker/default.nix +++ b/pkgs/build-support/docker/default.nix @@ -360,7 +360,9 @@ rec { extraCommands ? "" }: # Generate an executable script from the `runAsRoot` text. - let runAsRootScript = shellScript "run-as-root.sh" runAsRoot; + let + runAsRootScript = shellScript "run-as-root.sh" runAsRoot; + extraCommandsScript = shellScript "extra-commands.sh" extraCommands; in runWithOverlay { name = "docker-layer-${name}"; @@ -398,7 +400,7 @@ rec { ''; postUmount = '' - (cd layer; eval "${extraCommands}") + (cd layer; ${extraCommandsScript}) echo "Packing layer..." mkdir $out