summary refs log tree commit diff
path: root/pkgs/build-support
diff options
context:
space:
mode:
authorFrederik Rietdijk <fridh@fridh.nl>2017-07-17 13:52:01 +0200
committerFrederik Rietdijk <fridh@fridh.nl>2017-07-17 13:52:01 +0200
commit3eceecb90db691f22e46eb892bd7800f953d605e (patch)
treed7dae792d8f7a6f9eea7d8164e9849ab232d1d7d /pkgs/build-support
parent8e98811f76fa29e8a3782e9b0b0acc6d16926cac (diff)
parent8669fb1f96cfd68ed68d9d76ff1f0237d4d96748 (diff)
downloadnixlib-3eceecb90db691f22e46eb892bd7800f953d605e.tar
nixlib-3eceecb90db691f22e46eb892bd7800f953d605e.tar.gz
nixlib-3eceecb90db691f22e46eb892bd7800f953d605e.tar.bz2
nixlib-3eceecb90db691f22e46eb892bd7800f953d605e.tar.lz
nixlib-3eceecb90db691f22e46eb892bd7800f953d605e.tar.xz
nixlib-3eceecb90db691f22e46eb892bd7800f953d605e.tar.zst
nixlib-3eceecb90db691f22e46eb892bd7800f953d605e.zip
Merge remote-tracking branch 'upstream/master' into HEAD
Diffstat (limited to 'pkgs/build-support')
-rw-r--r--pkgs/build-support/docker/default.nix15
1 files changed, 9 insertions, 6 deletions
diff --git a/pkgs/build-support/docker/default.nix b/pkgs/build-support/docker/default.nix
index e06be51f4a4e..506ef7837a2e 100644
--- a/pkgs/build-support/docker/default.nix
+++ b/pkgs/build-support/docker/default.nix
@@ -234,11 +234,10 @@ rec {
     # Files to add to the layer.
     contents ? null,
     # Additional commands to run on the layer before it is tar'd up.
-    extraCommands ? ""
+    extraCommands ? "", uid ? 0, gid ? 0
   }:
     runCommand "docker-layer-${name}" {
       inherit baseJson contents extraCommands;
-
       buildInputs = [ jshon rsync ];
     }
     ''
@@ -253,6 +252,8 @@ rec {
         echo "No contents to add to layer."
       fi
 
+      chmod ug+w layer
+
       if [[ -n $extraCommands ]]; then
         (cd layer; eval "$extraCommands")
       fi
@@ -260,7 +261,7 @@ rec {
       # Tar up the layer and throw it into 'layer.tar'.
       echo "Packing layer..."
       mkdir $out
-      tar -C layer --mtime="@$SOURCE_DATE_EPOCH" -cf $out/layer.tar .
+      tar -C layer --mtime="@$SOURCE_DATE_EPOCH" --owner=${toString uid} --group=${toString gid} -cf $out/layer.tar .
 
       # Compute a checksum of the tarball.
       echo "Computing layer checksum..."
@@ -312,6 +313,8 @@ rec {
           echo "Adding $item..."
           rsync -ak --chown=0:0 $item/ layer/
         done
+
+        chmod ug+w layer
       '';
 
       postMount = ''
@@ -375,7 +378,7 @@ rec {
     # Docker config; e.g. what command to run on the container.
     config ? null,
     # Optional bash script to run on the files prior to fixturizing the layer.
-    extraCommands ? "",
+    extraCommands ? "", uid ? 0, gid ? 0,
     # Optional bash script to run as root on the image when provisioning.
     runAsRoot ? null,
     # Size of the virtual machine disk to provision when building the image.
@@ -398,7 +401,7 @@ rec {
         if runAsRoot == null
         then mkPureLayer {
           name = baseName;
-          inherit baseJson contents extraCommands;
+          inherit baseJson contents extraCommands uid gid;
         } else mkRootLayer {
           name = baseName;
           inherit baseJson fromImage fromImageName fromImageTag
@@ -498,7 +501,7 @@ rec {
         chmod -R a-w image
 
         echo "Cooking the image..."
-        tar -C image --mtime="@$SOURCE_DATE_EPOCH" -c . | pigz -nT > $out
+        tar -C image --mtime="@$SOURCE_DATE_EPOCH" --owner=0 --group=0 -c . | pigz -nT > $out
 
         echo "Finished."
       '';