{ stdenv, kernel, perl, libmpc }:

let
  baseBuildFlags = [ "INSTALL_HDR_PATH=$(out)" "headers_install" ];
in stdenv.mkDerivation {
  name = "linux-headers-${kernel.version}";

  inherit (kernel) src patches;

  nativeBuildInputs = [ perl libmpc ];

  buildFlags = [ "ARCH=${stdenv.platform.kernelArch}" ] ++ baseBuildFlags;

  crossAttrs = {
    inherit (kernel.crossDrv) src patches;
    buildFlags = [ "ARCH=${stdenv.cross.platform.kernelArch}" ] ++ baseBuildFlags;
  };

  installPhase = ''
    find $out \( -name ..install.cmd -o -name .install \) -print0 | xargs -0 rm
  '';

  # Headers shouldn't reference anything else
  allowedReferences = [];

  meta.platforms = stdenv.lib.platforms.linux;
}

{ stdenv, kernel, perl }:

let
  baseBuildFlags = [ "INSTALL_HDR_PATH=$(out)" "headers_install" ];
in stdenv.mkDerivation {
  name = "linux-headers-${kernel.version}";

  inherit (kernel) src patches;

  nativeBuildInputs = [ perl ];

  buildFlags = [ "ARCH=${stdenv.platform.kernelArch}" ] ++ baseBuildFlags;

  crossAttrs = {
    inherit (kernel.crossDrv) src patches;
    buildFlags = [ "ARCH=${stdenv.cross.platform.kernelArch}" ] ++ baseBuildFlags;
  };

  installPhase = ''
    find $out \( -name ..install.cmd -o -name .install \) -print0 | xargs -0 rm
  '';

  # Headers shouldn't reference anything else
  allowedReferences = [];

  meta.platforms = stdenv.lib.platforms.linux;
}

Revert "kernelHeaders: fix build with libmpc"
Revert "kernelHeaders: fix build with libmpc"

This reverts commit b0adde8f8a5f22cf45f32df64bba149f326dec85.

Doesn't fix the issue for grsec kernels.

(cherry picked from commit 22bd9c12fec43bf914cdbec4c3a11cd0d964912a)
Signed-off-by: Domen Kožar <d11d22f7dbd5ce2cc259c953391f3b291ef56fb5@dev.si>
