1{
2 stdenv,
3 pkgs,
4 lib,
5}:
6
7# ordering should match defaultNativeBuildInputs
8
9{
10 no-broken-symlinks = lib.recurseIntoAttrs (
11 import ./no-broken-symlinks.nix { inherit stdenv lib pkgs; }
12 );
13 # TODO: add audit-tmpdir
14 compress-man-pages =
15 let
16 manFile = pkgs.writeText "small-man" ''
17 .TH HELLO "1" "May 2022" "hello 2.12.1" "User Commands"
18 .SH NAME
19 hello - friendly greeting program
20 '';
21 in
22 stdenv.mkDerivation {
23 name = "test-compress-man-pages";
24 buildCommand = ''
25 mkdir -p $out/share/man
26 cp ${manFile} $out/share/man/small-man.1
27 compressManPages $out
28 [[ -e $out/share/man/small-man.1.gz ]]
29 '';
30 };
31 make-symlinks-relative = stdenv.mkDerivation {
32 name = "test-make-symlinks-relative";
33 outputs = [
34 "out"
35 "man"
36 ];
37 buildCommand = ''
38 mkdir -p $out/{bar,baz}
39 mkdir -p $man/share/{x,y}
40 source1="$out/bar/foo"
41 destination1="$out/baz/foo"
42 source2="$man/share/x/file1"
43 destination2="$man/share/y/file2"
44 echo foo > $source1
45 echo foo > $source2
46 ln -s $source1 $destination1
47 ln -s $source2 $destination2
48 echo "symlink before patching: $(readlink $destination1)"
49 echo "symlink before patching: $(readlink $destination2)"
50
51 _makeSymlinksRelativeInAllOutputs
52
53 echo "symlink after patching: $(readlink $destination1)"
54 ([[ -e $destination1 ]] && echo "symlink isn't broken") || (echo "symlink is broken" && exit 1)
55 ([[ $(readlink $destination1) == "../bar/foo" ]] && echo "absolute symlink was made relative") || (echo "symlink was not made relative" && exit 1)
56 echo "symlink after patching: $(readlink $destination2)"
57 ([[ -e $destination2 ]] && echo "symlink isn't broken") || (echo "symlink is broken" && exit 1)
58 ([[ $(readlink $destination2) == "../x/file1" ]] && echo "absolute symlink was made relative") || (echo "symlink was not made relative" && exit 1)
59 '';
60 };
61 move-docs = stdenv.mkDerivation {
62 name = "test-move-docs";
63 buildCommand = ''
64 mkdir -p $out/{man,doc,info}
65 touch $out/{man,doc,info}/foo
66 cat $out/{man,doc,info}/foo
67
68 _moveToShare
69
70 (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)
71 '';
72 };
73 move-lib64 = stdenv.mkDerivation {
74 name = "test-move-lib64";
75 buildCommand = ''
76 mkdir -p $out/lib64
77 touch $out/lib64/foo
78 cat $out/lib64/foo
79
80 _moveLib64
81
82 # check symlink
83 [[ -h $out/lib64 ]]
84 ([[ -e $out/lib64 ]] && echo "symlink isn't broken") || (echo "symlink is broken" && exit 1)
85 [[ -e $out/lib/foo ]]
86 '';
87 };
88 move-sbin = stdenv.mkDerivation {
89 name = "test-move-sbin";
90 buildCommand = ''
91 mkdir -p $out/sbin
92 touch $out/sbin/foo
93 cat $out/sbin/foo
94
95 _moveSbin
96
97 # check symlink
98 [[ -h $out/sbin ]]
99 ([[ -e $out/sbin ]] && echo "symlink isn't broken") || (echo "symlink is broken" && exit 1)
100 [[ -e $out/bin/foo ]]
101 '';
102 };
103 # TODO: add multiple-outputs
104 patch-shebangs = import ./patch-shebangs.nix { inherit stdenv lib pkgs; };
105 prune-libtool-files =
106 let
107 libFoo = pkgs.writeText "libFoo" ''
108 # Generated by libtool (GNU libtool) 2.4.6
109 old_library='''
110 dependency_libs=' -Lbar.la -Lbaz.la'
111 '';
112 in
113 stdenv.mkDerivation {
114 name = "test-prune-libtool-files";
115 buildCommand = ''
116 mkdir -p $out/lib
117 cp ${libFoo} $out/lib/libFoo.la
118 _pruneLibtoolFiles
119 grep "^dependency_libs=''' #pruned" $out/lib/libFoo.la
120 # confirm file doesn't only contain the above
121 grep "^old_library='''" $out/lib/libFoo.la
122 '';
123 };
124 reproducible-builds = stdenv.mkDerivation {
125 name = "test-reproducible-builds";
126 buildCommand = ''
127 # can't be tested more precisely because the value of random-seed changes depending on the output
128 [[ $NIX_CFLAGS_COMPILE =~ "-frandom-seed=" ]]
129 touch $out
130 '';
131 };
132 set-source-date-epoch-to-latest = stdenv.mkDerivation {
133 name = "test-set-source-date-epoch-to-latest";
134 buildCommand = ''
135 sourceRoot=$NIX_BUILD_TOP/source
136 mkdir -p $sourceRoot
137 touch --date=1/1/2015 $sourceRoot/foo
138
139 _updateSourceDateEpochFromSourceRoot
140
141 [[ $SOURCE_DATE_EPOCH == "1420070400" ]]
142 touch $out
143 '';
144 };
145 # TODO: add strip
146}