2021-01-14 07:24:27 +00:00
|
|
|
{ stdenv, linuxHeaders, parentWrapperDir, debug ? false }:
|
|
|
|
# For testing:
|
|
|
|
# $ nix-build -E 'with import <nixpkgs> {}; pkgs.callPackage ./wrapper.nix { parentWrapperDir = "/run/wrappers"; debug = true; }'
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
name = "security-wrapper";
|
|
|
|
buildInputs = [ linuxHeaders ];
|
|
|
|
dontUnpack = true;
|
|
|
|
hardeningEnable = [ "pie" ];
|
|
|
|
CFLAGS = [
|
2021-01-14 09:00:34 +00:00
|
|
|
''-DWRAPPER_DIR="${parentWrapperDir}"''
|
2021-01-14 07:24:27 +00:00
|
|
|
] ++ (if debug then [
|
|
|
|
"-Werror" "-Og" "-g"
|
|
|
|
] else [
|
|
|
|
"-Wall" "-O2"
|
|
|
|
]);
|
|
|
|
dontStrip = debug;
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/bin
|
|
|
|
$CC $CFLAGS ${./wrapper.c} -o $out/bin/security-wrapper
|
|
|
|
'';
|
|
|
|
}
|