Files
nixpkgs/pkgs/by-name/ma/makeBinaryWrapper/package.nix
Ihar Hrachyshka a919a6e611 makeBinaryWrapper: use GNU bintools for extractCmd
Only GNU supports the -d flag used. In a different environment, the
command fails as follows:

strings: error: unknown argument '-d'

Note: I believe it was not noticed because the command is used in
Firefox wrapper only where its failure is silently swallowed. The only
side effect then is that the wrapper won't work as expected when
wrapping a wrapper.

Signed-off-by: Ihar Hrachyshka <ihar.hrachyshka@gmail.com>
2025-04-03 20:48:17 -04:00

34 lines
863 B
Nix

{
targetPackages,
lib,
makeSetupHook,
dieHook,
writeShellScript,
tests,
cc ? targetPackages.stdenv.cc,
sanitizers ? [ ],
}:
makeSetupHook {
name = "make-binary-wrapper-hook";
propagatedBuildInputs = [ dieHook ];
substitutions = {
cc = "${cc}/bin/${cc.targetPrefix}cc ${
lib.escapeShellArgs (map (s: "-fsanitize=${s}") sanitizers)
+ lib.optionalString (
cc.isClang && !cc.stdenv.hostPlatform.isDarwin
) "--ld-path=${cc.targetPrefix}ld"
}";
};
passthru = {
# Extract the function call used to create a binary wrapper from its embedded docstring
extractCmd = writeShellScript "extract-binary-wrapper-cmd" ''
${targetPackages.gnuStdenv.cc.bintools.targetPrefix}strings -dw "$1" | sed -n '/^makeCWrapper/,/^$/ p'
'';
tests = tests.makeBinaryWrapper;
};
} ./make-binary-wrapper.sh