diff options
author | Milan Pässler <milan@petabyte.dev> | 2020-10-10 16:57:52 +0200 |
---|---|---|
committer | Milan Pässler <milan@petabyte.dev> | 2020-10-10 16:57:52 +0200 |
commit | 19ac914c4ec5a40165c50ed9d41f7490a2383fa4 (patch) | |
tree | 99bf23701df2016e5fc391ea8de3436c86d8ea6a /pkgs/coreboot/default.nix | |
parent | 38ab1843819e461543749c8a849a2d876ed6002e (diff) |
.
Diffstat (limited to 'pkgs/coreboot/default.nix')
-rw-r--r-- | pkgs/coreboot/default.nix | 77 |
1 files changed, 75 insertions, 2 deletions
diff --git a/pkgs/coreboot/default.nix b/pkgs/coreboot/default.nix index abe6548fd299..9e224c71a727 100644 --- a/pkgs/coreboot/default.nix +++ b/pkgs/coreboot/default.nix @@ -1,3 +1,76 @@ +{ fetchgit +, fetchurl +, stdenv +, m4 +, flex +, bison +, zlib +, gnat +, curl +, writeText +, callPackage +, lib +, corebootConfig ? { CONFIG_PAYLOAD_NONE = "y"; } +}: - # ${tianocore-coreboot}/FV/UEFIPAYLOAD.fd - # ${grub-coreboot}/default_payload.elf +let + version = "4.12"; + src = fetchgit { + url = "https://review.coreboot.org/coreboot.git"; + rev = "${version}"; + fetchSubmodules = true; + sha256 = "1l140zbvn6pkbrr55lymhi4lycimhpy8xgm45shl4zv6a9vjd66z"; + }; + + toolchain = stdenv.mkDerivation rec { + pname = "coreboot-toolchain"; + inherit 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 {})} + NIX_HARDENING_ENABLE="$\{NIX_HARDENING_ENABLE/ format/\}" make crossgcc-i386 CPUS=$NIX_BUILD_CORES + ''; + installPhase = '' + cp -r util/crossgcc $out + ''; + }; + + filteredConfig = lib.filterAttrs (n: v: v != null) corebootConfig; + lines = lib.mapAttrsToList (name: value: "${name}=${value}") filteredConfig; + configFile = writeText "config" (lib.concatStringsSep "\n" lines); +in stdenv.mkDerivation rec { + + pname = "coreboot"; + inherit version src; + + configurePhase = '' + cp ${configFile} .config + make olddefconfig + ''; + + buildPhase = '' + rm -rf util/crossgcc + cp -r ${toolchain} util/crossgcc + chmod u+rwX -R util/crossgcc + patchShebangs util/xcompile/xcompile + make + ''; + + installPhase = '' + mkdir -p $out + cp build/coreboot.rom $out + ''; + + passthru = { + inherit toolchain configFile; + }; +} |