aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md9
-rw-r--r--configs/boards/t440p.nix8
-rw-r--r--configs/boards/t60.nix6
-rw-r--r--configs/boards/x1c.nix6
-rw-r--r--configs/boards/x220.nix6
-rw-r--r--configs/boards/x230-fhd.nix9
-rw-r--r--configs/boards/x230.nix6
-rw-r--r--configs/boards/x230t.nix4
-rw-r--r--configs/common.nix11
-rw-r--r--configs/milan-x1c.nix15
-rw-r--r--flake.lock27
-rw-r--r--flake.nix23
-rw-r--r--modules/coreboot/default.nix44
-rw-r--r--modules/default.nix9
-rw-r--r--modules/grub2/default.nix20
-rw-r--r--pkgs/coreboot-base/default.nix73
-rw-r--r--pkgs/coreboot-payload-grub2/default.nix2
-rw-r--r--pkgs/coreboot/default.nix77
-rw-r--r--pkgs/coreboot/files.nix (renamed from pkgs/coreboot-base/files.nix)7
-rw-r--r--pkgs/overlay.nix2
l---------result1
21 files changed, 284 insertions, 81 deletions
diff --git a/README.md b/README.md
new file mode 100644
index 000000000000..19949e60462d
--- /dev/null
+++ b/README.md
@@ -0,0 +1,9 @@
+Features:
+
+- Specify config overrides as Nix attribute set
+- Change payload without rebuilding coreboot
+
+Limitations:
+
+- currently only `x86_64-linux` host and target systems are supported
+- It's not yet possible to build with a SeaBIOS payload
diff --git a/configs/boards/t440p.nix b/configs/boards/t440p.nix
new file mode 100644
index 000000000000..5d3f29e7e68f
--- /dev/null
+++ b/configs/boards/t440p.nix
@@ -0,0 +1,8 @@
+{ ... }:
+
+{
+ CONFIG_VENDOR_LENOVO = "y";
+ CONFIG_BOARD_LENOVO_THINKPAD_T440P = "y";
+
+ # TODO: fetch mrc.bin
+}
diff --git a/configs/boards/t60.nix b/configs/boards/t60.nix
new file mode 100644
index 000000000000..9af80af158ff
--- /dev/null
+++ b/configs/boards/t60.nix
@@ -0,0 +1,6 @@
+{ ... }:
+
+{
+ CONFIG_VENDOR_LENOVO = "y";
+ CONFIG_BOARD_LENOVO_T60 = "y";
+}
diff --git a/configs/boards/x1c.nix b/configs/boards/x1c.nix
new file mode 100644
index 000000000000..c2a3774dadc2
--- /dev/null
+++ b/configs/boards/x1c.nix
@@ -0,0 +1,6 @@
+{ ... }:
+
+{
+ CONFIG_VENDOR_LENOVO = "y";
+ CONFIG_BOARD_LENOVO_X1_CARBON_GEN1 = "y";
+}
diff --git a/configs/boards/x220.nix b/configs/boards/x220.nix
new file mode 100644
index 000000000000..4db72bcbb94d
--- /dev/null
+++ b/configs/boards/x220.nix
@@ -0,0 +1,6 @@
+{ ... }:
+
+{
+ CONFIG_VENDOR_LENOVO = "y";
+ CONFIG_BOARD_LENOVO_X220 = "y";
+}
diff --git a/configs/boards/x230-fhd.nix b/configs/boards/x230-fhd.nix
new file mode 100644
index 000000000000..bb198aba4826
--- /dev/null
+++ b/configs/boards/x230-fhd.nix
@@ -0,0 +1,9 @@
+{ ... }:
+
+{
+ imports = [
+ ./x230.nix
+ ];
+
+ # TODO: modify vbt to hide LVDS
+}
diff --git a/configs/boards/x230.nix b/configs/boards/x230.nix
new file mode 100644
index 000000000000..5563f11fdbad
--- /dev/null
+++ b/configs/boards/x230.nix
@@ -0,0 +1,6 @@
+{ ... }:
+
+{
+ CONFIG_VENDOR_LENOVO = "y";
+ CONFIG_BOARD_LENOVO_X230 = "y";
+}
diff --git a/configs/boards/x230t.nix b/configs/boards/x230t.nix
new file mode 100644
index 000000000000..884b314b96b3
--- /dev/null
+++ b/configs/boards/x230t.nix
@@ -0,0 +1,4 @@
+{
+ CONFIG_VENDOR_LENOVO = "y";
+ CONFIG_BOARD_LENOVO_X230T = "y";
+}
diff --git a/configs/common.nix b/configs/common.nix
new file mode 100644
index 000000000000..113860f7ea7e
--- /dev/null
+++ b/configs/common.nix
@@ -0,0 +1,11 @@
+{ ... }:
+
+{
+ coreboot.corebootConfig = {
+ CONFIG_PAYLOAD_NONE = "y"; # payload is added later
+ CONFIG_CBFS_SIZE = lib.mkDefault "0x300000";
+ CONFIG_USE_OPTION_TABLE = lib.mkDefault "y";
+ CONFIG_PCIEXP_CLK_PM = lib.mkDefault "y";
+ CONFIG_GENERIC_LINEAR_FRAMEBUFFER = lib.mkDefault "y";
+ };
+}
diff --git a/configs/milan-x1c.nix b/configs/milan-x1c.nix
new file mode 100644
index 000000000000..b88474a210f8
--- /dev/null
+++ b/configs/milan-x1c.nix
@@ -0,0 +1,15 @@
+{ ... }:
+
+{
+ imports = [
+ ./common.nix
+ ./boards/x1c.nix
+ ];
+
+ coreboot.corebootConfig = {
+ CONFIG_LINEAR_FRAMEBUFFER_MAX_WIDTH = "1600";
+ CONFIG_LINEAR_FRAMEBUFFER_MAX_HEIGHT = "900";
+ };
+
+ grub2.enable = true;
+}
diff --git a/flake.lock b/flake.lock
new file mode 100644
index 000000000000..cebe99b6e4dc
--- /dev/null
+++ b/flake.lock
@@ -0,0 +1,27 @@
+{
+ "nodes": {
+ "nixpkgs": {
+ "locked": {
+ "lastModified": 1602333914,
+ "narHash": "sha256-ossU2LFWerfPK/HkCvAom6WvBrQ80vq9CTApMCPaHMs=",
+ "owner": "nixos",
+ "repo": "nixpkgs",
+ "rev": "b70ac01b380722591c89d40ea31e0ac2463d87ec",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nixos",
+ "ref": "master",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "root": {
+ "inputs": {
+ "nixpkgs": "nixpkgs"
+ }
+ }
+ },
+ "root": "root",
+ "version": 7
+}
diff --git a/flake.nix b/flake.nix
index c1e63c7018fd..99be3070f2ee 100644
--- a/flake.nix
+++ b/flake.nix
@@ -8,6 +8,27 @@
description = "A collections of derivations for coreboot and payloads";
outputs = { self, nixpkgs }: {
- packages = (import ./pkgs/overlay.nix) nixpkgs;
+ packages.x86_64-linux = let
+ pkgs = import nixpkgs {
+ system = "x86_64-linux";
+ overlays = [
+ (import ./pkgs/overlay.nix)
+ ];
+ };
+ inherit (pkgs) lib;
+
+ makeDevice = configFile:
+ with lib.evalModules {
+ modules = [
+ ./modules
+ configFile
+ ];
+ };
+ system.config.coreboot.rom;
+ in {
+ inherit (pkgs) coreboot-payload-grub2 coreboot-payload-tianocore coreboot;
+
+ milan-x1c = makeDevice ./configs/milan-x1c.nix;
+ };
};
}
diff --git a/modules/coreboot/default.nix b/modules/coreboot/default.nix
new file mode 100644
index 000000000000..aeeb4426f6d4
--- /dev/null
+++ b/modules/coreboot/default.nix
@@ -0,0 +1,44 @@
+{ config, pkgs, lib, ... }:
+
+with lib;
+
+let
+ cfg = config.coreboot;
+in {
+ options.coreboot = {
+ extraFiles = mkOption {
+ type = types.attrs;
+ };
+ corebootConfig = mkOption {
+ type = types.attrs;
+ };
+ rom = mkOption {
+ readOnly = true;
+ type = types.path;
+ };
+ };
+
+ config = {
+ coreboot.rom = let
+ base = pkgs.coreboot.override {
+ inherit (cfg) corebootConfig;
+ };
+
+ filteredFiles = filterAttrs (k: v: v != null) cfg.extraFiles;
+ filesList = mapAttrsToList (k: v: v // { name = v; }) filteredFiles;
+
+ installCommands = concatMapStringsSep "\n" (file: ''
+ cbfstool $out add \
+ -f ${file.src} \
+ -n ${file.name} \
+ -t ${file.type}
+ '') filesList;
+
+ in runCommand "coreboot-rom" {
+ buildInputs = with pkgs; [ cbfstool ];
+ } ''
+ install -D ${base}/coreboot.rom -t $out
+ ${installCommands}
+ '';
+ };
+}
diff --git a/modules/default.nix b/modules/default.nix
new file mode 100644
index 000000000000..6012f715f372
--- /dev/null
+++ b/modules/default.nix
@@ -0,0 +1,9 @@
+{ ... }:
+
+{
+ imports = [
+ ./coreboot
+ ./grub2
+ #./tianocore
+ ];
+}
diff --git a/modules/grub2/default.nix b/modules/grub2/default.nix
new file mode 100644
index 000000000000..c8790b880081
--- /dev/null
+++ b/modules/grub2/default.nix
@@ -0,0 +1,20 @@
+{ lib, pkgs, ... }:
+
+with lib;
+
+let
+ cfg = config.grub2;
+in {
+ options.grub2 = {
+ enable = mkEnableOption "grub2 coreboot primary payload";
+ };
+
+ config = lib.mkIf cfg.enable {
+ coreboot.rom.extraFiles = {
+ "fallback/payload" = {
+ type = "payload";
+ src = "${pkgs.coreboot-payload-grub}/default_payload.elf";
+ };
+ };
+ };
+}
diff --git a/pkgs/coreboot-base/default.nix b/pkgs/coreboot-base/default.nix
deleted file mode 100644
index 3b8fe28f29be..000000000000
--- a/pkgs/coreboot-base/default.nix
+++ /dev/null
@@ -1,73 +0,0 @@
-{ 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-payload-grub2/default.nix b/pkgs/coreboot-payload-grub2/default.nix
index 0d90ef805fd5..c01d4065ecfe 100644
--- a/pkgs/coreboot-payload-grub2/default.nix
+++ b/pkgs/coreboot-payload-grub2/default.nix
@@ -4,7 +4,7 @@
}:
grub2.overrideAttrs (oA: {
- name = "coreboot-payload-${oA.name}";
+ pname = "coreboot-payload-${oA.pname}";
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/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;
+ };
+}
diff --git a/pkgs/coreboot-base/files.nix b/pkgs/coreboot/files.nix
index 3e3e3a7f92b6..f5d71ec46b53 100644
--- a/pkgs/coreboot-base/files.nix
+++ b/pkgs/coreboot/files.nix
@@ -4,9 +4,10 @@
[
(rec {
version = "6.1.2";
+ name = "gmp-${version}.tar.xz";
archive = fetchurl {
sha256 = "04hrwahdxyqdik559604r7wrj9ffklwvipgfxgj4ys4skbl6bdc7";
- url = "mirror://gnu/gmp/gmp-${version}.tar.xz";
+ url = "mirror://gnu/gmp/${name}";
};
})
@@ -48,7 +49,7 @@
(rec {
version = "20200110";
- name = "apica-unix2-${version}.tar.gz";
+ name = "acpica-unix2-${version}.tar.gz";
archive = fetchurl {
sha256 = "1hb4g6r7w8s4bhlkk36fmb4qxghnrwvad7f18cpn6zz0b4sjs7za";
url = "https://acpica.org/sites/acpica/files/${name}";
@@ -60,7 +61,7 @@
name = "nasm-${version}.tar.bz2";
archive = fetchurl {
sha256 = "1g409sr1kj7v1089s9kv0i4azvddkcwcypnbakfryyi71b3jdz9l";
- url = "https://www.nasm.us/pub/nasm/releasebuilds/${version}.tar.bz2";
+ url = "https://www.nasm.us/pub/nasm/releasebuilds/${version}/${name}";
};
})
]
diff --git a/pkgs/overlay.nix b/pkgs/overlay.nix
index 7fcbfb43ac6c..b600349970bc 100644
--- a/pkgs/overlay.nix
+++ b/pkgs/overlay.nix
@@ -1,7 +1,7 @@
final: prev:
let inherit (final) callPackage;
in {
- coreboot-base = callPackage ./coreboot-base {};
+ coreboot = callPackage ./coreboot {};
coreboot-payload-grub2 = callPackage ./coreboot-payload-grub2 {};
coreboot-payload-tianocore = callPackage ./coreboot-payload-tianocore {};
}
diff --git a/result b/result
new file mode 120000
index 000000000000..6f6205ff0393
--- /dev/null
+++ b/result
@@ -0,0 +1 @@
+/nix/store/pmmavhwnwrlfsxh9jsm58qx76zc2xl2m-coreboot-4.12 \ No newline at end of file