about summary refs log tree commit diff
path: root/pkgs/build-support
diff options
context:
space:
mode:
authorRobert Hensing <roberth@users.noreply.github.com>2020-06-19 12:01:47 +0200
committerGitHub <noreply@github.com>2020-06-19 12:01:47 +0200
commit06469493de41e1cdb8bdd4b8f1e563d1e8dfd0aa (patch)
treead6b086be043b90471008af8939360d36d66b7b9 /pkgs/build-support
parent36429a4e59750271ffd2b90836646ac840c45641 (diff)
parent2dd94af18650aee1b53c9509832068b60c1b1225 (diff)
Merge pull request #91085 from hercules-ci/fix-dockerTools-nix-symlinks
Fix docker tools nix symlinks
Diffstat (limited to 'pkgs/build-support')
-rw-r--r--pkgs/build-support/docker/examples.nix22
-rwxr-xr-xpkgs/build-support/docker/store-path-to-layer.sh10
2 files changed, 29 insertions, 3 deletions
diff --git a/pkgs/build-support/docker/examples.nix b/pkgs/build-support/docker/examples.nix
index d533e3abd03bd..b040d830b31c0 100644
--- a/pkgs/build-support/docker/examples.nix
+++ b/pkgs/build-support/docker/examples.nix
@@ -121,6 +121,7 @@ rec {
       # the image env variable NIX_PAGER.
       pkgs.coreutils
       pkgs.nix
+      pkgs.bash
     ];
     config = {
       Env = [
@@ -313,4 +314,25 @@ rec {
       )
     ];
   };
+
+  nixLayered = pkgs.dockerTools.buildLayeredImageWithNixDb {
+    name = "nix-layered";
+    tag = "latest";
+    contents = [
+      # nix-store uses cat program to display results as specified by
+      # the image env variable NIX_PAGER.
+      pkgs.coreutils
+      pkgs.nix
+      pkgs.bash
+    ];
+    config = {
+      Env = [
+        "NIX_PAGER=cat"
+        # A user is required by nix
+        # https://github.com/NixOS/nix/blob/9348f9291e5d9e4ba3c4347ea1b235640f54fd79/src/libutil/util.cc#L478
+        "USER=nobody"
+      ];
+    };
+  };
+
 }
diff --git a/pkgs/build-support/docker/store-path-to-layer.sh b/pkgs/build-support/docker/store-path-to-layer.sh
index 7437da51cc4a4..3a1fcd0c27a18 100755
--- a/pkgs/build-support/docker/store-path-to-layer.sh
+++ b/pkgs/build-support/docker/store-path-to-layer.sh
@@ -16,7 +16,11 @@ mkdir -p "$layerPath"
 # when there are other things being added to the
 # nix store, tar could fail, saying,
 # "tar: /nix/store: file changed as we read it"
-mkdir -p nix/store
+#
+# In addition, we use `__Nix__` instead of `nix` to avoid renaming
+# relative symlink destinations like
+# /nix/store/...-nix-2.3.4/bin/nix-daemon -> nix
+mkdir -p __Nix__/store
 
 # Then we change into the /nix/store in order to
 # avoid a similar "file changed as we read it" error
@@ -35,8 +39,8 @@ tarhash=$(
       --hard-dereference --sort=name \
       --mtime="@$SOURCE_DATE_EPOCH" \
       --owner=0 --group=0 \
-      --transform 's,^nix$,/\0,' \
-      --transform 's,^nix/store$,/\0,' \
+      --transform 's,^__Nix__$,/nix,' \
+      --transform 's,^__Nix__/store$,/nix/store,' \
       --transform 's,^[^/],/nix/store/\0,rS' |
     tee "$layerPath/layer.tar" |
     tarsum