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