2023-10-04 19:16:06 +00:00
|
|
|
{
|
|
|
|
stdenv,
|
|
|
|
unsecvars,
|
|
|
|
linuxHeaders,
|
|
|
|
sourceProg,
|
|
|
|
debug ? false,
|
|
|
|
}:
|
2021-01-14 08:24:27 +01:00
|
|
|
# For testing:
|
2023-09-13 19:16:42 +02:00
|
|
|
# $ nix-build -E 'with import <nixpkgs> {}; pkgs.callPackage ./wrapper.nix { sourceProg = "${pkgs.hello}/bin/hello"; debug = true; }'
|
2021-01-14 08:24:27 +01:00
|
|
|
stdenv.mkDerivation {
|
2023-09-13 19:16:42 +02:00
|
|
|
name = "security-wrapper-${baseNameOf sourceProg}";
|
2021-01-14 08:24:27 +01:00
|
|
|
buildInputs = [ linuxHeaders ];
|
|
|
|
dontUnpack = true;
|
|
|
|
CFLAGS =
|
|
|
|
[
|
2022-11-05 00:09:32 +01:00
|
|
|
''-DSOURCE_PROG="${sourceProg}"''
|
2021-01-14 08:24:27 +01:00
|
|
|
]
|
|
|
|
++ (
|
|
|
|
if debug then
|
|
|
|
[
|
|
|
|
"-Werror"
|
|
|
|
"-Og"
|
|
|
|
"-g"
|
|
|
|
]
|
|
|
|
else
|
|
|
|
[
|
|
|
|
"-Wall"
|
|
|
|
"-O2"
|
|
|
|
]
|
|
|
|
);
|
|
|
|
dontStrip = debug;
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/bin
|
2023-10-04 19:16:06 +00:00
|
|
|
$CC $CFLAGS ${./wrapper.c} -I${unsecvars} -o $out/bin/security-wrapper
|
2021-01-14 08:24:27 +01:00
|
|
|
'';
|
|
|
|
}
|