summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--pkgs/build-support/setup-hooks/make-symlinks-relative.sh2
-rw-r--r--pkgs/test/default.nix2
-rw-r--r--pkgs/test/hooks/default.nix28
3 files changed, 31 insertions, 1 deletions
diff --git a/pkgs/build-support/setup-hooks/make-symlinks-relative.sh b/pkgs/build-support/setup-hooks/make-symlinks-relative.sh
index 0608d3ca81c..cd9c2eaa2d8 100644
--- a/pkgs/build-support/setup-hooks/make-symlinks-relative.sh
+++ b/pkgs/build-support/setup-hooks/make-symlinks-relative.sh
@@ -1,4 +1,4 @@
-fixupOutputHooks+=(_makeSymlinksRelative)
+postFixupHooks+=(_makeSymlinksRelative)
 
 # For every symlink in $output that refers to another file in $output
 # ensure that the symlink is relative. This removes references to the output
diff --git a/pkgs/test/default.nix b/pkgs/test/default.nix
index e72afbb3998..b687092f514 100644
--- a/pkgs/test/default.nix
+++ b/pkgs/test/default.nix
@@ -26,6 +26,8 @@ with pkgs;
 
   haskell = callPackage ./haskell { };
 
+  hooks = callPackage ./hooks { };
+
   cc-multilib-gcc = callPackage ./cc-wrapper/multilib.nix { stdenv = gccMultiStdenv; };
   cc-multilib-clang = callPackage ./cc-wrapper/multilib.nix { stdenv = clangMultiStdenv; };
 
diff --git a/pkgs/test/hooks/default.nix b/pkgs/test/hooks/default.nix
new file mode 100644
index 00000000000..fe3a9b2a216
--- /dev/null
+++ b/pkgs/test/hooks/default.nix
@@ -0,0 +1,28 @@
+# To run these tests:
+# nix-build -A tests.hooks
+
+{ stdenv, pkgs, lib }:
+
+{
+  # this attrset is for hooks in `stdenv.defaultNativeBuildInputs`
+  default-stdenv-hooks = lib.recurseIntoAttrs {
+    make-symlinks-relative = stdenv.mkDerivation {
+      name = "test-make-symlinks-relative";
+      passAsFile = [ "buildCommand" ];
+      buildCommand = ''
+        mkdir -p $out/{bar,baz}
+        source1="$out/bar/foo"
+        destination1="$out/baz/foo"
+        echo foo > $source1
+        ln -s $source1 $destination1
+        echo "symlink before patching: $(readlink $destination1)"
+
+        _makeSymlinksRelative
+
+        echo "symlink after patching: $(readlink $destination1)"
+        ([[ -e $destination1 ]] && echo "symlink isn't broken") || (echo "symlink is broken" && exit 1)
+        ([[ $(readlink $destination1) == "../bar/foo" ]] && echo "absolute symlink was made relative") || (echo "symlink was not made relative" && exit 1)
+      '';
+    };
+  };
+}