aboutsummaryrefslogtreecommitdiff
path: root/pkgs/coreboot-base/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/coreboot-base/default.nix')
-rw-r--r--pkgs/coreboot-base/default.nix73
1 files changed, 73 insertions, 0 deletions
diff --git a/pkgs/coreboot-base/default.nix b/pkgs/coreboot-base/default.nix
new file mode 100644
index 000000000000..3b8fe28f29be
--- /dev/null
+++ b/pkgs/coreboot-base/default.nix
@@ -0,0 +1,73 @@
+{ fetchgit
+, fetchurl
+, stdenv
+, m4
+, flex
+, bison
+, zlib
+, gnat
+, curl
+, grub-coreboot
+, tianocore-coreboot
+, perl
+, writeText
+, config ? {}
+}:
+
+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
+ ${}
+ NIX_HARDENING_ENABLE="$\{NIX_HARDENING_ENABLE/ format/\}" make crossgcc-i386 CPUS=$NIX_BUILD_CORES
+ '';
+ installPhase = ''
+ cp -r util/crossgcc $out
+ '';
+ };
+
+in stdenv.mkDerivation rec {
+ pname = "coreboot";
+ inherit version src;
+ configurePhase = let
+ filteredConfig = lib.filterAttrs (n: v: v != null) config;
+ lines = lib.mapAttrsToList (name: value: "${name}=${value}") filteredConfig;
+ configFile = writeText "config" (concatStringsSept "\n" lines);
+ in ''
+ 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;
+ };
+}