@@ -0,0 +1,104 @@
1+{ stdenv, fetchurl, zlib, pciutils, coreutils, acpica-tools, iasl, makeWrapper, gnugrep, gnused, file, buildEnv }:
2+
3+let
4+ version = "4.10";
5+
6+ meta = with stdenv.lib; {
7+ description = "Various coreboot-related tools";
8+ homepage = "https://www.coreboot.org";
9+ license = licenses.gpl2;
10+ maintainers = [ maintainers.petabyteboy ];
11+ platforms = platforms.linux;
12+ };
13+
14+ generic = { pname, path ? "util/${pname}", ... }@args: stdenv.mkDerivation (rec {
15+ inherit pname version meta;
16+
17+ src = fetchurl {
18+ url = "https://coreboot.org/releases/coreboot-${version}.tar.xz";
19+ sha256 = "1jsiz17afi2lqg1jv6lsl8s05w7vr7iwgg86y2qp369hcz6kcwfa";
20+ };
21+
22+ enableParallelBuilding = true;
23+
24+ postPatch = ''
25+ cd ${path}
26+ '';
27+
28+ makeFlags = [
29+ "INSTALL=install"
30+ "PREFIX=${placeholder "out"}"
31+ ];
32+ } // args);
33+
34+ utils = {
35+ msrtool = generic {
36+ pname = "msrtool";
37+ meta.description = "Dump chipset-specific MSR registers";
38+ buildInputs = [ pciutils zlib ];
39+ preConfigure = "export INSTALL=install";
40+ };
41+ cbmem = generic {
42+ pname = "cbmem";
43+ meta.description = "Coreboot console log reader";
44+ };
45+ ifdtool = generic {
46+ pname = "ifdtool";
47+ meta.description = "Extract and dump Intel Firmware Descriptor information";
48+ };
49+ intelmetool = generic {
50+ pname = "intelmetool";
51+ meta.description = "Dump interesting things about Management Engine";
52+ buildInputs = [ pciutils zlib ];
53+ };
54+ cbfstool = generic {
55+ pname = "cbfstool";
56+ meta.description = "Management utility for CBFS formatted ROM images";
57+ };
58+ nvramtool = generic {
59+ pname = "nvramtool";
60+ meta.description = "Read and write coreboot parameters and display information from the coreboot table in CMOS/NVRAM";
61+ };
62+ superiotool = generic {
63+ pname = "superiotool";
64+ meta.description = "User-space utility to detect Super I/O of a mainboard and provide detailed information about the register contents of the Super I/O";
65+ buildInputs = [ pciutils zlib ];
66+ };
67+ ectool = generic {
68+ pname = "ectool";
69+ meta.description = "Dump the RAM of a laptop's Embedded/Environmental Controller (EC)";
70+ meta.platforms = [ "x86_64-linux" "i686-linux" ];
71+ preInstall = "mkdir -p $out/sbin";
72+ };
73+ inteltool = generic {
74+ pname = "inteltool";
75+ meta.description = "Provides information about Intel CPU/chipset hardware configuration (register contents, MSRs, etc)";
76+ buildInputs = [ pciutils zlib ];
77+ };
78+ amdfwtool = generic {
79+ pname = "amdfwtool";
80+ meta.description = "Create AMD firmware combination";
81+ installPhase = "install -Dm755 amdfwtool $out/bin/amdfwtool";
82+ };
83+ acpidump-all = generic {
84+ pname = "acpidump-all";
85+ path = "util/acpi";
86+ meta.description = "Walk through all ACPI tables with their addresses";
87+ nativeBuildInputs = [ makeWrapper ];
88+ dontBuild = true;
89+ installPhase = "install -Dm755 acpidump-all $out/bin/acpidump-all";
90+ postFixup = let
91+ binPath = [ coreutils acpica-tools iasl gnugrep gnused file ];
92+ in "wrapProgram $out/bin/acpidump-all --set PATH ${stdenv.lib.makeBinPath binPath}";
93+ };
94+ };
95+
96+in utils // {
97+ coreboot-utils = (buildEnv {
98+ name = "coreboot-utils-${version}";
99+ paths = stdenv.lib.attrValues utils;
100+ postBuild = "rm -rf $out/sbin";
101+ }) // {
102+ inherit meta version;
103+ };
104+}