nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ stdenv }:
2crateName: metadata: buildTests:
3if !buildTests then
4 ''
5 runHook preInstall
6 # always create $out even if we do not have binaries. We are detecting binary targets during compilation, if those are missing there is no way to only have $lib
7 mkdir $out
8 if [[ -s target/env ]]; then
9 mkdir -p $lib
10 cp target/env $lib/env
11 fi
12 if [[ -s target/link.final ]]; then
13 mkdir -p $lib/lib
14 cp target/link.final $lib/lib/link
15 fi
16 if [[ "$(ls -A target/lib)" ]]; then
17 mkdir -p $lib/lib
18 cp -r target/lib/* $lib/lib #*/
19 for library in $lib/lib/*.so $lib/lib/*.dylib; do #*/
20 ln -s $library $(echo $library | sed -e "s/-${metadata}//")
21 done
22 fi
23 if [[ "$(ls -A target/build)" ]]; then # */
24 mkdir -p $lib/lib
25 cp -r target/build/* $lib/lib # */
26 fi
27 if [[ -d target/bin ]]; then
28 if [[ "$(ls -A target/bin)" ]]; then
29 mkdir -p $out/bin
30 cp -rP target/bin/* $out/bin # */
31 fi
32 fi
33 runHook postInstall
34 ''
35else
36 # for tests we just put them all in the output. No execution.
37 ''
38 runHook preInstall
39
40 mkdir -p $out/tests
41 if [ -e target/bin ]; then
42 find target/bin/ -type f -executable -exec cp {} $out/tests \;
43 fi
44 if [ -e target/lib ]; then
45 find target/lib/ -type f \! -name '*.rlib' \
46 -a \! -name '*${stdenv.hostPlatform.extensions.library}' \
47 -a \! -name '*.d' \
48 -executable \
49 -print0 | xargs --no-run-if-empty --null install --target $out/tests;
50 fi
51
52 runHook postInstall
53 ''