nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 177 lines 4.9 kB view raw
1{ 2 initialBash, 3 initialPath, 4 stdenv, 5 pkgs, 6 lib, 7}: 8 9# ordering should match defaultNativeBuildInputs 10 11{ 12 no-broken-symlinks = lib.recurseIntoAttrs ( 13 import ./no-broken-symlinks.nix { inherit stdenv lib pkgs; } 14 ); 15 # TODO: add audit-tmpdir 16 compress-man-pages = 17 let 18 manFile = pkgs.writeText "small-man" '' 19 .TH HELLO "1" "May 2022" "hello 2.12.1" "User Commands" 20 .SH NAME 21 hello - friendly greeting program 22 ''; 23 in 24 stdenv.mkDerivation { 25 name = "test-compress-man-pages"; 26 buildCommand = '' 27 mkdir -p $out/share/man 28 cp ${manFile} $out/share/man/small-man.1 29 compressManPages $out 30 [[ -e $out/share/man/small-man.1.gz ]] 31 ''; 32 }; 33 # test based on stage0 to minimize rebuilds 34 make-symlinks-relative = 35 (derivation { 36 name = "test-make-symlinks-relative"; 37 system = stdenv.system; 38 builder = "${initialBash}/bin/bash"; 39 inherit initialPath; 40 outputs = [ 41 "out" 42 "out2" 43 ]; 44 args = [ 45 "-c" 46 '' 47 set -euo pipefail 48 . ${../../stdenv/generic/setup.sh} 49 . ${../../build-support/setup-hooks/make-symlinks-relative.sh} 50 51 mkdir -p $out $out2 52 53 # create symlink targets 54 touch $out/target $out2/target 55 56 # link within out 57 ln -s $out/target $out/linkToOut 58 59 # link across different outputs 60 ln -s $out2/target $out/linkToOut2 61 62 # broken link 63 ln -s $out/does-not-exist $out/brokenLink 64 65 # call hook 66 _makeSymlinksRelative 67 68 # verify link within out became relative 69 echo "readlink linkToOut: $(readlink $out/linkToOut)" 70 if test "$(readlink $out/linkToOut)" != 'target'; then 71 echo "Expected relative link, got: $(readlink $out/linkToOut)" 72 exit 1 73 fi 74 75 # verify link across outputs is still absolute 76 if test "$(readlink $out/linkToOut2)" != "$out2/target"; then 77 echo "Expected absolute link, got: $(readlink $out/linkToOut2)" 78 exit 1 79 fi 80 81 # verify broken link was made relative 82 if test "$(readlink $out/brokenLink)" != 'does-not-exist'; then 83 echo "Expected relative broken link, got: $(readlink $out/brokenLink)" 84 exit 1 85 fi 86 '' 87 ]; 88 }) 89 // { 90 meta = { }; 91 }; 92 move-docs = stdenv.mkDerivation { 93 name = "test-move-docs"; 94 buildCommand = '' 95 mkdir -p $out/{man,doc,info} 96 touch $out/{man,doc,info}/foo 97 cat $out/{man,doc,info}/foo 98 99 _moveToShare 100 101 (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) 102 ''; 103 }; 104 move-lib64 = stdenv.mkDerivation { 105 name = "test-move-lib64"; 106 buildCommand = '' 107 mkdir -p $out/lib64 108 touch $out/lib64/foo 109 cat $out/lib64/foo 110 111 _moveLib64 112 113 # check symlink 114 [[ -h $out/lib64 ]] 115 ([[ -e $out/lib64 ]] && echo "symlink isn't broken") || (echo "symlink is broken" && exit 1) 116 [[ -e $out/lib/foo ]] 117 ''; 118 }; 119 move-sbin = stdenv.mkDerivation { 120 name = "test-move-sbin"; 121 buildCommand = '' 122 mkdir -p $out/sbin 123 touch $out/sbin/foo 124 cat $out/sbin/foo 125 126 _moveSbin 127 128 # check symlink 129 [[ -h $out/sbin ]] 130 ([[ -e $out/sbin ]] && echo "symlink isn't broken") || (echo "symlink is broken" && exit 1) 131 [[ -e $out/bin/foo ]] 132 ''; 133 }; 134 # TODO: add multiple-outputs 135 patch-shebangs = import ./patch-shebangs.nix { inherit stdenv lib pkgs; }; 136 prune-libtool-files = 137 let 138 libFoo = pkgs.writeText "libFoo" '' 139 # Generated by libtool (GNU libtool) 2.4.6 140 old_library=''' 141 dependency_libs=' -Lbar.la -Lbaz.la' 142 ''; 143 in 144 stdenv.mkDerivation { 145 name = "test-prune-libtool-files"; 146 buildCommand = '' 147 mkdir -p $out/lib 148 cp ${libFoo} $out/lib/libFoo.la 149 _pruneLibtoolFiles 150 grep "^dependency_libs=''' #pruned" $out/lib/libFoo.la 151 # confirm file doesn't only contain the above 152 grep "^old_library='''" $out/lib/libFoo.la 153 ''; 154 }; 155 reproducible-builds = stdenv.mkDerivation { 156 name = "test-reproducible-builds"; 157 buildCommand = '' 158 # can't be tested more precisely because the value of random-seed changes depending on the output 159 [[ $NIX_CFLAGS_COMPILE =~ "-frandom-seed=" ]] 160 touch $out 161 ''; 162 }; 163 set-source-date-epoch-to-latest = stdenv.mkDerivation { 164 name = "test-set-source-date-epoch-to-latest"; 165 buildCommand = '' 166 sourceRoot=$NIX_BUILD_TOP/source 167 mkdir -p $sourceRoot 168 touch --date=1/1/2015 $sourceRoot/foo 169 170 _updateSourceDateEpochFromSourceRoot 171 172 [[ $SOURCE_DATE_EPOCH == "1420070400" ]] 173 touch $out 174 ''; 175 }; 176 # TODO: add strip 177}