aboutsummaryrefslogtreecommitdiff
path: root/infra/corenix/pkgs/coreboot
diff options
context:
space:
mode:
Diffstat (limited to 'infra/corenix/pkgs/coreboot')
-rw-r--r--infra/corenix/pkgs/coreboot/default.nix62
-rw-r--r--infra/corenix/pkgs/coreboot/files.nix67
2 files changed, 129 insertions, 0 deletions
diff --git a/infra/corenix/pkgs/coreboot/default.nix b/infra/corenix/pkgs/coreboot/default.nix
new file mode 100644
index 000000000000..cc0c2f39b209
--- /dev/null
+++ b/infra/corenix/pkgs/coreboot/default.nix
@@ -0,0 +1,62 @@
+{ fetchgit, fetchurl, stdenv, m4, flex, bison, zlib, gnat, curl, writeText
+, callPackage, lib, corebootConfig ? { CONFIG_PAYLOAD_NONE = "y"; } }:
+
+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
+ '';
+ };
+
+ 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;
+
+in stdenv.mkDerivation rec {
+
+ pname = "coreboot";
+ inherit version src;
+
+ 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; };
+}
diff --git a/infra/corenix/pkgs/coreboot/files.nix b/infra/corenix/pkgs/coreboot/files.nix
new file mode 100644
index 000000000000..f5d71ec46b53
--- /dev/null
+++ b/infra/corenix/pkgs/coreboot/files.nix
@@ -0,0 +1,67 @@
+{ fetchurl }:
+
+# from util/crossgcc/buildgcc
+[
+ (rec {
+ version = "6.1.2";
+ name = "gmp-${version}.tar.xz";
+ archive = fetchurl {
+ sha256 = "04hrwahdxyqdik559604r7wrj9ffklwvipgfxgj4ys4skbl6bdc7";
+ url = "mirror://gnu/gmp/${name}";
+ };
+ })
+
+ (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 = "acpica-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}/${name}";
+ };
+ })
+]