Luke Granger-Brown
57725ef3ec
git-subtree-dir: third_party/nixpkgs git-subtree-split: 76612b17c0ce71689921ca12d9ffdc9c23ce40b2
31 lines
634 B
Nix
31 lines
634 B
Nix
# binfmt preserve-argv[0] wrapper
|
|
#
|
|
# More details in binfmt-p-wrapper.c
|
|
#
|
|
# The wrapper has to be static so LD_* environment variables
|
|
# cannot affect the execution of the wrapper itself.
|
|
|
|
{ lib, stdenv, pkgsStatic, enableDebug ? false }:
|
|
|
|
name: emulator:
|
|
|
|
pkgsStatic.stdenv.mkDerivation {
|
|
inherit name;
|
|
|
|
src = ./binfmt-p-wrapper.c;
|
|
|
|
dontUnpack = true;
|
|
dontInstall = true;
|
|
|
|
buildPhase = ''
|
|
runHook preBuild
|
|
|
|
mkdir -p $out/bin
|
|
$CC -o $out/bin/${name} -static -std=c99 -O2 \
|
|
-DTARGET_QEMU=\"${emulator}\" \
|
|
${lib.optionalString enableDebug "-DDEBUG"} \
|
|
$src
|
|
|
|
runHook postBuild
|
|
'';
|
|
}
|