My personal project and infrastructure archive
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
nomicon/infra/corenix/pkgs/coreboot/default.nix

64 lines
1.7 KiB

{ fetchgit, fetchurl, stdenv, m4, flex, bison, zlib, gnat, curl, writeText
, callPackage, lib, corebootConfig ? { CONFIG_PAYLOAD_NONE = "y"; } }:
let
toolchain = stdenv.mkDerivation rec {
pname = "coreboot-toolchain";
inherit (coreboot) version src;
nativeBuildInputs = [ curl stdenv m4 flex bison zlib gnat ];
buildPhase = ''
mkdir -p util/crossgcc/tarballs
${lib.concatMapStringsSep "\n"
(file: "ln -s ${file.archive} util/crossgcc/tarballs/${file.name}")
(callPackage ./files.nix { })}
make crossgcc-i386 CPUS=$NIX_BUILD_CORES
'';
installPhase = ''
cp -r util/crossgcc $out
'';
};
writeConfig = config: let
filteredConfig = lib.filterAttrs (n: v: v != null) config;
lines =
lib.mapAttrsToList (name: value: "${name}=${value}") filteredConfig;
configFile = writeText "config" (lib.concatStringsSep "\n" lines);
in configFile;
coreboot = stdenv.mkDerivation rec {
pname = "coreboot";
version = "4.13";
src = fetchgit {
url = "https://review.coreboot.org/coreboot.git";
rev = version;
sha256 = "sha256-O5udH6RAfs5IPqzvluXAApU7TDow39aOEewL5+nln3c=";
fetchSubmodules = true;
};
postPatch = ''
rm -rf util/crossgcc
cp -r ${toolchain} util/crossgcc
chmod u+rwX -R util/crossgcc
patchShebangs util/xcompile/xcompile
'';
configurePhase = ''
runHook preConfigure
cp ${writeConfig corebootConfig} .config
make olddefconfig
runHook postConfigure
'';
installPhase = ''
mkdir -p $out
cp build/coreboot.rom $out
'';
passthru = { inherit toolchain writeConfig corebootConfig; };
};
in coreboot