summary refs log tree commit diff
path: root/pkgs/build-support/docker
diff options
context:
space:
mode:
authorGraham Christensen <graham@grahamc.com>2019-12-16 12:57:04 -0500
committerGraham Christensen <graham@grahamc.com>2019-12-16 12:57:04 -0500
commit700f4c538885bb9c1290d1723ec5380c2fe6e910 (patch)
tree809b3b9c2fe728c29ceae54595924fb54b94640b /pkgs/build-support/docker
parentaec80dddc0416722a421330316003f27cf0c566b (diff)
downloadnixpkgs-700f4c538885bb9c1290d1723ec5380c2fe6e910.tar
nixpkgs-700f4c538885bb9c1290d1723ec5380c2fe6e910.tar.gz
nixpkgs-700f4c538885bb9c1290d1723ec5380c2fe6e910.tar.bz2
nixpkgs-700f4c538885bb9c1290d1723ec5380c2fe6e910.tar.lz
nixpkgs-700f4c538885bb9c1290d1723ec5380c2fe6e910.tar.xz
nixpkgs-700f4c538885bb9c1290d1723ec5380c2fe6e910.tar.zst
nixpkgs-700f4c538885bb9c1290d1723ec5380c2fe6e910.zip
dockerTools.buildLayeredImage: prepare to exclude some paths
Without changing behavior, since this code is fiddly, make it possible
to add a filtering step before packaging individual paths.
Diffstat (limited to 'pkgs/build-support/docker')
-rw-r--r--pkgs/build-support/docker/default.nix11
1 files changed, 8 insertions, 3 deletions
diff --git a/pkgs/build-support/docker/default.nix b/pkgs/build-support/docker/default.nix
index 77edbb76601..eb3863bcfba 100644
--- a/pkgs/build-support/docker/default.nix
+++ b/pkgs/build-support/docker/default.nix
@@ -319,15 +319,20 @@ 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
       # following head and tail call lines, double-check that your
       # code behaves properly when the number of layers equals:
       #      maxLayers-1, maxLayers, and maxLayers+1
-      head -n $((maxLayers - 1)) $paths | cat -n | xargs -P$NIX_BUILD_CORES -n2 ${storePathToLayer}
-      if [ $(cat $paths | wc -l) -ge $maxLayers ]; then
-        tail -n+$maxLayers $paths | xargs ${storePathToLayer} $maxLayers
+      paths() {
+        cat $paths
+      }
+
+      paths | head -n $((maxLayers - 1)) | cat -n | xargs -P$NIX_BUILD_CORES -n2 ${storePathToLayer}
+      if [ $(paths | wc -l) -ge $maxLayers ]; then
+        paths | tail -n+$maxLayers | xargs ${storePathToLayer} $maxLayers
       fi
 
       echo "Finished building layer '$name'"