summary refs log tree commit diff
path: root/pkgs/build-support/docker/default.nix
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2020-01-26 22:39:25 +0000
committerAlyssa Ross <hi@alyssa.is>2020-01-26 22:39:25 +0000
commitbd2ad77e38991af0d7a3a5d82bd3f41a077ce401 (patch)
treed1e26d039eb5004eb7c836aafff259cc198626d4 /pkgs/build-support/docker/default.nix
parente5d8381542a8d084371d26013fab199f52474be7 (diff)
parentad3f0d9829119b611350a9be1c226fb625f1f310 (diff)
downloadnixpkgs-bd2ad77e38991af0d7a3a5d82bd3f41a077ce401.tar
nixpkgs-bd2ad77e38991af0d7a3a5d82bd3f41a077ce401.tar.gz
nixpkgs-bd2ad77e38991af0d7a3a5d82bd3f41a077ce401.tar.bz2
nixpkgs-bd2ad77e38991af0d7a3a5d82bd3f41a077ce401.tar.lz
nixpkgs-bd2ad77e38991af0d7a3a5d82bd3f41a077ce401.tar.xz
nixpkgs-bd2ad77e38991af0d7a3a5d82bd3f41a077ce401.tar.zst
nixpkgs-bd2ad77e38991af0d7a3a5d82bd3f41a077ce401.zip
Merge remote-tracking branch 'nixpkgs/master' into master
Diffstat (limited to 'pkgs/build-support/docker/default.nix')
-rw-r--r--pkgs/build-support/docker/default.nix18
1 files changed, 16 insertions, 2 deletions
diff --git a/pkgs/build-support/docker/default.nix b/pkgs/build-support/docker/default.nix
index e10ff269950..3fcae13e20d 100644
--- a/pkgs/build-support/docker/default.nix
+++ b/pkgs/build-support/docker/default.nix
@@ -325,7 +325,6 @@ rec {
         | jshon -d config \
         | jshon -s "1970-01-01T00:00:01Z" -i created > generic.json
 
-
       # WARNING!
       # The following code is fiddly w.r.t. ensuring every layer is
       # created, and that no paths are missed. If you change the
@@ -625,7 +624,22 @@ rec {
           -i "$imageName" > image/repositories
 
         echo "Cooking the image..."
-        tar -C image --dereference --hard-dereference --sort=name --mtime="@$SOURCE_DATE_EPOCH" --owner=0 --group=0  --mode=a-w --xform s:'^./':: -c . | pigz -nT > $out
+        # tar exits with an exit code of 1 if files changed while it was
+        # reading them. It considers a change in the number of hard links
+        # to be a "change", which can cause this to fail if images are being
+        # built concurrently and the auto-optimise-store nix option is turned on.
+        # Since the contents of these files will not change, we can reasonably
+        # ignore this exit code.
+        set +e
+        tar -C image --dereference --hard-dereference --sort=name \
+          --mtime="@$SOURCE_DATE_EPOCH" --owner=0 --group=0  \
+          --mode=a-w --xform s:'^./':: --use-compress-program='pigz -nT' \
+          --warning=no-file-changed -cf $out .
+        RET=$?
+        if [ $RET -ne 0 ] && [ $RET -ne 1 ]; then
+          exit $RET
+        fi
+        set -e
 
         echo "Finished."
       '';