2021-01-14 08:24:27 +01: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 10:00:34 +01:00
|
|
|
''-DWRAPPER_DIR="${parentWrapperDir}"''
|
2021-01-14 08:24:27 +01: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
|
|
|
|
'';
|
|
|
|
}
|