aboutsummaryrefslogtreecommitdiff
path: root/pkgs
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/coreboot-base/default.nix73
-rw-r--r--pkgs/coreboot-base/files.nix66
-rw-r--r--pkgs/coreboot-payload-grub2/default.nix11
-rw-r--r--pkgs/coreboot-payload-tianocore/default.nix78
-rw-r--r--pkgs/coreboot/default.nix3
-rw-r--r--pkgs/overlay.nix7
6 files changed, 238 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;
+ };
+}
diff --git a/pkgs/coreboot-base/files.nix b/pkgs/coreboot-base/files.nix
new file mode 100644
index 000000000000..3e3e3a7f92b6
--- /dev/null
+++ b/pkgs/coreboot-base/files.nix
@@ -0,0 +1,66 @@
+{ fetchurl }:
+
+# from util/crossgcc/buildgcc
+[
+ (rec {
+ version = "6.1.2";
+ archive = fetchurl {
+ sha256 = "04hrwahdxyqdik559604r7wrj9ffklwvipgfxgj4ys4skbl6bdc7";
+ url = "mirror://gnu/gmp/gmp-${version}.tar.xz";
+ };
+ })
+
+ (rec {
+ version = "4.0.2";
+ name = "mpfr-${version}.tar.xz";
+ archive = fetchurl {
+ sha256 = "12m3amcavhpqygc499s3fzqlb8f2j2rr7fkqsm10xbjfc04fffqx";
+ url = "mirror://gnu/mpfr/${name}";
+ };
+ })
+
+ (rec {
+ version = "1.1.0";
+ name = "mpc-${version}.tar.gz";
+ archive = fetchurl {
+ sha256 = "0biwnhjm3rx3hc0rfpvyniky4lpzsvdcwhmcn7f0h4iw2hwcb1b9";
+ url = "mirror://gnu/mpc/${name}";
+ };
+ })
+
+ (rec {
+ version = "8.3.0";
+ name = "gcc-${version}.tar.xz";
+ archive = fetchurl {
+ sha256 = "0b3xv411xhlnjmin2979nxcbnidgvzqdf4nbhix99x60dkzavfk4";
+ url = "mirror://gnu/gcc/${name}";
+ };
+ })
+
+ (rec {
+ version = "2.33.1";
+ name = "binutils-${version}.tar.xz";
+ archive = fetchurl {
+ sha256 = "1grcf8jaw3i0bk6f9xfzxw3qfgmn6fgkr108isdkbh1y3hnzqrmb";
+ url = "mirror://gnu/binutils/${name}";
+ };
+ })
+
+ (rec {
+ version = "20200110";
+ name = "apica-unix2-${version}.tar.gz";
+ archive = fetchurl {
+ sha256 = "1hb4g6r7w8s4bhlkk36fmb4qxghnrwvad7f18cpn6zz0b4sjs7za";
+ url = "https://acpica.org/sites/acpica/files/${name}";
+ };
+ })
+
+ (rec {
+ version = "2.14.02";
+ name = "nasm-${version}.tar.bz2";
+ archive = fetchurl {
+ sha256 = "1g409sr1kj7v1089s9kv0i4azvddkcwcypnbakfryyi71b3jdz9l";
+ url = "https://www.nasm.us/pub/nasm/releasebuilds/${version}.tar.bz2";
+ };
+ })
+]
diff --git a/pkgs/coreboot-payload-grub2/default.nix b/pkgs/coreboot-payload-grub2/default.nix
new file mode 100644
index 000000000000..0d90ef805fd5
--- /dev/null
+++ b/pkgs/coreboot-payload-grub2/default.nix
@@ -0,0 +1,11 @@
+{ grub2
+, lib
+, extraPayloadModules ? [ "png" "gfxmenu" "gfxterm_background" "ls" "cat" "echo" "linux" "xfs" "bsd" ]
+}:
+
+grub2.overrideAttrs (oA: {
+ name = "coreboot-payload-${oA.name}";
+ configureFlags = oA.configureFlags ++ [ "--with-platform=coreboot" "--enable-boot-time" ];
+ postBuild = "make -j $NIX_BUILD_CORES default_payload.elf EXTRA_PAYLOAD_MODULES=\"${lib.concatStringsSep " " extraPayloadModules}\"";
+ installPhase = "install -D default_payload.elf -t $out";
+})
diff --git a/pkgs/coreboot-payload-tianocore/default.nix b/pkgs/coreboot-payload-tianocore/default.nix
new file mode 100644
index 000000000000..8d9c29dc5329
--- /dev/null
+++ b/pkgs/coreboot-payload-tianocore/default.nix
@@ -0,0 +1,78 @@
+{ fetchFromGitHub, python2, stdenv, libuuid, bc, utillinux, nasm, iasl, seabios }:
+
+# we can not override the source in edk2, so we had to copy the entire thing
+
+let
+ src = fetchFromGitHub {
+ owner = "MrChromebox";
+ repo = "edk2";
+ rev = "860a8d95c2ee89c9916d6e11230f246afa1cd629";
+ sha256 = "1bykw3lzfjl6idca37i736mwpqv60haczp7davhgqlmlb3nw6y3s";
+ fetchSubmodules = true;
+ };
+
+ version = "unstable";
+
+ pythonEnv = python2.withPackages (ps: [ps.tkinter]);
+
+ toolchain = stdenv.mkDerivation {
+ pname = "edk2-coreboot";
+
+ inherit version src;
+
+ buildInputs = [ libuuid pythonEnv ];
+
+ makeFlags = [ "-C BaseTools" ];
+
+ NIX_CFLAGS_COMPILE = "-Wno-return-type -Wno-error=stringop-truncation";
+
+ hardeningDisable = [ "format" "fortify" ];
+
+ installPhase = ''
+ mkdir -vp $out
+ mv -v BaseTools $out
+ mv -v edksetup.sh $out
+ '';
+
+ enableParallelBuilding = true;
+ };
+
+in
+ stdenv.mkDerivation {
+ pname = "coreboot-payload-tianocore";
+ inherit version src;
+
+ buildInputs = [ bc pythonEnv utillinux nasm iasl ];
+
+ prePatch = ''
+ rm -rf BaseTools
+ ln -sv ${toolchain}/BaseTools BaseTools
+ '';
+
+ configurePhase = ''
+ runHook preConfigure
+ export WORKSPACE="$PWD"
+ . ${toolchain}/edksetup.sh BaseTools
+ runHook postConfigure
+ '';
+
+ buildPhase = ''
+ runHook preBuild
+ build -a X64 -a IA32 -b RELEASE -t GCC5 -p CorebootPayloadPkg/CorebootPayloadPkgIa32X64.dsc -n $NIX_BUILD_CORES -D CSM_ENABLE
+ runHook postBuild
+ '';
+
+ installPhase = ''
+ runHook preInstall
+ mv -v Build/*/* $out
+ runHook postInstall
+ '';
+
+ hardeningDisable = [ "format" "stackprotector" "pic" "fortify" ];
+
+ postPatch = ''
+ cp ${seabios}/Csm16.bin OvmfPkg/Csm/Csm16/Csm16.bin
+ '';
+
+ dontPatchELF = true;
+ }
diff --git a/pkgs/coreboot/default.nix b/pkgs/coreboot/default.nix
new file mode 100644
index 000000000000..abe6548fd299
--- /dev/null
+++ b/pkgs/coreboot/default.nix
@@ -0,0 +1,3 @@
+
+ # ${tianocore-coreboot}/FV/UEFIPAYLOAD.fd
+ # ${grub-coreboot}/default_payload.elf
diff --git a/pkgs/overlay.nix b/pkgs/overlay.nix
new file mode 100644
index 000000000000..7fcbfb43ac6c
--- /dev/null
+++ b/pkgs/overlay.nix
@@ -0,0 +1,7 @@
+final: prev:
+let inherit (final) callPackage;
+in {
+ coreboot-base = callPackage ./coreboot-base {};
+ coreboot-payload-grub2 = callPackage ./coreboot-payload-grub2 {};
+ coreboot-payload-tianocore = callPackage ./coreboot-payload-tianocore {};
+}