2021-04-12 18:23:04 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, kernel ? null
|
2024-04-21 15:54:59 +00:00
|
|
|
, elfutils
|
2021-04-12 18:23:04 +00:00
|
|
|
, nasm
|
|
|
|
, python3
|
|
|
|
, withDriver ? false
|
|
|
|
}:
|
|
|
|
|
|
|
|
python3.pkgs.buildPythonApplication rec {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "chipsec";
|
2023-05-24 13:37:59 +00:00
|
|
|
version = "1.10.6";
|
2022-02-10 20:34:41 +00:00
|
|
|
|
2021-04-12 18:23:04 +00:00
|
|
|
disabled = !stdenv.isLinux;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "chipsec";
|
|
|
|
repo = "chipsec";
|
|
|
|
rev = version;
|
2023-05-24 13:37:59 +00:00
|
|
|
hash = "sha256-+pbFG1SmSO/cnt1e+kel7ereC0I1OCJKKsS0KaJDWdc=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-04-12 18:23:04 +00:00
|
|
|
patches = lib.optionals withDriver [ ./ko-path.diff ./compile-ko.diff ];
|
|
|
|
|
|
|
|
KSRC = lib.optionalString withDriver "${kernel.dev}/lib/modules/${kernel.modDirVersion}/build";
|
2020-10-07 09:15:18 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
nativeBuildInputs = [
|
2021-04-12 18:23:04 +00:00
|
|
|
nasm
|
2024-04-21 15:54:59 +00:00
|
|
|
] ++ lib.optionals (lib.meta.availableOn stdenv.buildPlatform elfutils) [
|
|
|
|
elfutils
|
2023-05-24 13:37:59 +00:00
|
|
|
] ++ lib.optionals withDriver kernel.moduleBuildDependencies;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeCheckInputs = with python3.pkgs; [
|
2022-02-10 20:34:41 +00:00
|
|
|
distro
|
|
|
|
pytestCheckHook
|
2021-04-12 18:23:04 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
preBuild = lib.optionalString withDriver ''
|
|
|
|
export CHIPSEC_BUILD_LIB=$(mktemp -d)
|
|
|
|
mkdir -p $CHIPSEC_BUILD_LIB/chipsec/helper/linux
|
|
|
|
'';
|
|
|
|
|
2023-03-04 12:14:45 +00:00
|
|
|
env.NIX_CFLAGS_COMPILE = toString [
|
2023-02-16 17:41:37 +00:00
|
|
|
# Needed with GCC 12
|
|
|
|
"-Wno-error=dangling-pointer"
|
|
|
|
];
|
|
|
|
|
2021-04-12 18:23:04 +00:00
|
|
|
preInstall = lib.optionalString withDriver ''
|
|
|
|
mkdir -p $out/${python3.pkgs.python.sitePackages}/drivers/linux
|
|
|
|
mv $CHIPSEC_BUILD_LIB/chipsec/helper/linux/chipsec.ko \
|
|
|
|
$out/${python3.pkgs.python.sitePackages}/drivers/linux/chipsec.ko
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-02-10 20:34:41 +00:00
|
|
|
setupPyBuildFlags = [
|
|
|
|
"--build-lib=$CHIPSEC_BUILD_LIB"
|
2022-10-30 15:09:59 +00:00
|
|
|
] ++ lib.optionals (!withDriver) [
|
2022-02-10 20:34:41 +00:00
|
|
|
"--skip-driver"
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-02-10 20:34:41 +00:00
|
|
|
pythonImportsCheck = [
|
|
|
|
"chipsec"
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Platform Security Assessment Framework";
|
|
|
|
longDescription = ''
|
|
|
|
CHIPSEC is a framework for analyzing the security of PC platforms
|
|
|
|
including hardware, system firmware (BIOS/UEFI), and platform components.
|
|
|
|
It includes a security test suite, tools for accessing various low level
|
|
|
|
interfaces, and forensic capabilities. It can be run on Windows, Linux,
|
|
|
|
Mac OS X and UEFI shell.
|
|
|
|
'';
|
2021-04-12 18:23:04 +00:00
|
|
|
license = licenses.gpl2Only;
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "https://github.com/chipsec/chipsec";
|
2023-05-24 13:37:59 +00:00
|
|
|
maintainers = with maintainers; [ johnazoidberg erdnaxe ];
|
2022-06-16 17:23:12 +00:00
|
|
|
platforms = [ "x86_64-linux" ] ++ lib.optional (!withDriver) "x86_64-darwin";
|
2023-05-24 13:37:59 +00:00
|
|
|
# https://github.com/chipsec/chipsec/issues/1793
|
|
|
|
broken = withDriver && kernel.kernelOlder "5.4" && kernel.isHardened;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|