about summary refs log tree commit diff
path: root/pkgs/test/stdenv/hooks.nix
blob: f63ca054e08386c01f9efc2078b965e4659e1d04 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
{ stdenv }:

# ordering should match defaultNativeBuildInputs

{
  move-docs = stdenv.mkDerivation {
    name = "test-move-docs";
    buildCommand = ''
      mkdir -p $out/{man,doc,info}
      touch $out/{man,doc,info}/foo
      cat $out/{man,doc,info}/foo

      _moveToShare

      (cat $out/share/{man,doc,info}/foo 2>/dev/null && echo "man,doc,info were moved") || (echo "man,doc,info were not moved" && exit 1)
    '';
  };
  make-symlinks-relative = stdenv.mkDerivation {
    name = "test-make-symlinks-relative";
    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)
    '';
  };
}