nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 targetPackages,
3 lib,
4 makeSetupHook,
5 dieHook,
6 writeShellScript,
7 tests,
8 cc ? targetPackages.stdenv.cc,
9 sanitizers ? [ ],
10}:
11
12makeSetupHook {
13 name = "make-binary-wrapper-hook";
14 propagatedBuildInputs = [ dieHook ];
15
16 substitutions = {
17 cc = "${cc}/bin/${cc.targetPrefix}cc ${
18 lib.escapeShellArgs (map (s: "-fsanitize=${s}") sanitizers)
19 + lib.optionalString (
20 cc.isClang && !cc.stdenv.hostPlatform.isDarwin
21 ) "--ld-path=${cc.targetPrefix}ld"
22 }";
23 };
24
25 passthru = {
26 # Extract the function call used to create a binary wrapper from its embedded docstring
27 extractCmd = writeShellScript "extract-binary-wrapper-cmd" ''
28 ${targetPackages.gnuStdenv.cc.bintools.targetPrefix}strings -dw "$1" | sed -n '/^makeCWrapper/,/^$/ p'
29 '';
30
31 tests = tests.makeBinaryWrapper;
32 };
33} ./make-binary-wrapper.sh