aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMilan Pässler <milan@petabyte.dev>2020-10-11 21:06:30 +0200
committerMilan Pässler <milan@petabyte.dev>2020-10-12 12:27:12 +0200
commit53b6b4673d12b72519f5bc76f451305ac941b1b4 (patch)
tree7ea6b5e82a088a642cce31f0ca40e9bc4d06dd02
parentb00e192187b0df94682712d5ba5a88c923a6b0ce (diff)
add seabios
-rw-r--r--configs/boards/t440p.nix2
-rw-r--r--configs/boards/t60.nix2
-rw-r--r--configs/boards/x1c.nix2
-rw-r--r--configs/boards/x220.nix2
-rw-r--r--configs/boards/x230.nix2
-rw-r--r--configs/boards/x230t.nix2
-rw-r--r--configs/milan-x1c.nix2
-rw-r--r--flake.nix1
-rw-r--r--modules/coreinfo/default.nix1
-rw-r--r--modules/corenix/default.nix42
-rw-r--r--modules/default.nix1
-rw-r--r--modules/seabios/default.nix64
-rw-r--r--pkgs/coreboot-payload-coreinfo/default.nix15
-rw-r--r--pkgs/coreboot-payload-nvramcui/default.nix4
-rw-r--r--pkgs/coreboot-payload-seabios/default.nix27
-rw-r--r--pkgs/coreboot-payload-tianocore/default.nix11
-rw-r--r--pkgs/coreboot-payload-tint/default.nix5
-rw-r--r--pkgs/coreboot/default.nix13
-rw-r--r--pkgs/overlay.nix5
19 files changed, 170 insertions, 33 deletions
diff --git a/configs/boards/t440p.nix b/configs/boards/t440p.nix
index a4e9057831ab..c61f438e00aa 100644
--- a/configs/boards/t440p.nix
+++ b/configs/boards/t440p.nix
@@ -6,5 +6,7 @@
CONFIG_BOARD_LENOVO_THINKPAD_T440P = "y";
};
+ seabios.ps2Timeout = 5000;
+
# TODO: fetch mrc.bin
}
diff --git a/configs/boards/t60.nix b/configs/boards/t60.nix
index b2c073f55664..3528594ac4e6 100644
--- a/configs/boards/t60.nix
+++ b/configs/boards/t60.nix
@@ -5,4 +5,6 @@
CONFIG_VENDOR_LENOVO = "y";
CONFIG_BOARD_LENOVO_T60 = "y";
};
+
+ seabios.ps2Timeout = 5000;
}
diff --git a/configs/boards/x1c.nix b/configs/boards/x1c.nix
index e4e969a693e0..a67c2a731ddd 100644
--- a/configs/boards/x1c.nix
+++ b/configs/boards/x1c.nix
@@ -5,4 +5,6 @@
CONFIG_VENDOR_LENOVO = "y";
CONFIG_BOARD_LENOVO_X1_CARBON_GEN1 = "y";
};
+
+ seabios.ps2Timeout = 5000;
}
diff --git a/configs/boards/x220.nix b/configs/boards/x220.nix
index 0a493f82f1c8..6385e7a379be 100644
--- a/configs/boards/x220.nix
+++ b/configs/boards/x220.nix
@@ -5,4 +5,6 @@
CONFIG_VENDOR_LENOVO = "y";
CONFIG_BOARD_LENOVO_X220 = "y";
};
+
+ seabios.ps2Timeout = 5000;
}
diff --git a/configs/boards/x230.nix b/configs/boards/x230.nix
index fede99dbe9e5..293fc81c560d 100644
--- a/configs/boards/x230.nix
+++ b/configs/boards/x230.nix
@@ -5,4 +5,6 @@
CONFIG_VENDOR_LENOVO = "y";
CONFIG_BOARD_LENOVO_X230 = "y";
};
+
+ seabios.ps2Timeout = 5000;
}
diff --git a/configs/boards/x230t.nix b/configs/boards/x230t.nix
index 0ef3ea4e9809..6ae211ae6dc5 100644
--- a/configs/boards/x230t.nix
+++ b/configs/boards/x230t.nix
@@ -5,4 +5,6 @@
CONFIG_VENDOR_LENOVO = "y";
CONFIG_BOARD_LENOVO_X230T = "y";
};
+
+ seabios.ps2Timeout = 5000;
}
diff --git a/configs/milan-x1c.nix b/configs/milan-x1c.nix
index 2aa75cfbd19b..41238461e287 100644
--- a/configs/milan-x1c.nix
+++ b/configs/milan-x1c.nix
@@ -12,6 +12,8 @@
};
grub2.enable = true;
+ seabios.enable = true;
+ seabios.asSecondaryPayload = true;
coreinfo.enable = true;
nvramcui.enable = true;
tint.enable = true;
diff --git a/flake.nix b/flake.nix
index 5cf96ba82f04..a4c6161d73c3 100644
--- a/flake.nix
+++ b/flake.nix
@@ -34,6 +34,7 @@
coreboot
coreboot-payload-grub2
coreboot-payload-tianocore
+ coreboot-payload-seabios
coreboot-payload-tint
coreboot-payload-nvramcui
coreboot-payload-coreinfo;
diff --git a/modules/coreinfo/default.nix b/modules/coreinfo/default.nix
index d163b021204e..775bb11cb56e 100644
--- a/modules/coreinfo/default.nix
+++ b/modules/coreinfo/default.nix
@@ -7,6 +7,7 @@ let
in {
options.coreinfo = {
enable = mkEnableOption "coreinfo coreboot secondary payload";
+
coreinfoConfig = mkOption {
type = types.attrsOf (types.nullOr types.str);
default = {};
diff --git a/modules/corenix/default.nix b/modules/corenix/default.nix
index 3586cf0a904b..94698782f62e 100644
--- a/modules/corenix/default.nix
+++ b/modules/corenix/default.nix
@@ -9,6 +9,7 @@ let
src = mkOption {
type = types.path;
};
+
type = mkOption {
type = types.str;
default = "raw";
@@ -16,13 +17,19 @@ let
};
in {
options.corenix = {
+ installCommands = mkOption {
+ type = types.lines;
+ };
+
extraFiles = mkOption {
type = types.attrsOf (types.submodule fileOptions);
};
+
corebootConfig = mkOption {
type = types.attrsOf (types.nullOr types.str);
default = {};
};
+
rom = mkOption {
readOnly = true;
type = types.path;
@@ -30,32 +37,31 @@ in {
};
config = {
+ corenix.installCommands = let
+ filteredFiles = filterAttrs (k: v: v != null) cfg.extraFiles;
+ filesList = mapAttrsToList (k: v: v // { name = k; }) filteredFiles;
+ in concatMapStringsSep "\n" (file:
+ if file.type == "payload" then ''
+ cbfstool $out/coreboot.rom add-payload \
+ -f "${file.src}" \
+ -n "${file.name}" \
+ '' else ''
+ cbfstool $out/coreboot.rom add \
+ -f "${file.src}" \
+ -n "${file.name}" \
+ -t "${file.type}"
+ ''
+ ) filesList;
+
corenix.rom = let
base = pkgs.coreboot.override {
inherit (cfg) corebootConfig;
};
-
- filteredFiles = filterAttrs (k: v: v != null) cfg.extraFiles;
- filesList = mapAttrsToList (k: v: v // { name = k; }) filteredFiles;
-
- installCommands = concatMapStringsSep "\n" (file:
- if file.type == "payload" then ''
- cbfstool $out/coreboot.rom add-payload \
- -f "${file.src}" \
- -n "${file.name}" \
- '' else ''
- cbfstool $out/coreboot.rom add \
- -f "${file.src}" \
- -n "${file.name}" \
- -t "${file.type}"
- ''
- ) filesList;
-
in pkgs.runCommand "coreboot-rom" {
buildInputs = with pkgs; [ cbfstool ];
} ''
install -D ${base}/coreboot.rom -t $out
- ${installCommands}
+ ${cfg.installCommands}
'';
};
}
diff --git a/modules/default.nix b/modules/default.nix
index b42465acdbd3..c35a9ebc4caa 100644
--- a/modules/default.nix
+++ b/modules/default.nix
@@ -5,6 +5,7 @@
./corenix
./grub2
./tianocore
+ ./seabios
./tint
./nvramcui
./coreinfo
diff --git a/modules/seabios/default.nix b/modules/seabios/default.nix
new file mode 100644
index 000000000000..d48e36387442
--- /dev/null
+++ b/modules/seabios/default.nix
@@ -0,0 +1,64 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+ cfg = config.seabios;
+ payloadName = if cfg.asSecondaryPayload then
+ "img/seabios"
+ else
+ "fallback/payload";
+
+in {
+ options.seabios = {
+ enable = mkEnableOption "seabios coreboot primary payload";
+
+ withVgaBios = mkOption {
+ type = types.bool;
+ default = true;
+ };
+
+ asSecondaryPayload = mkOption {
+ type = types.bool;
+ default = false;
+ };
+
+ ps2Timeout = mkOption {
+ type = types.int;
+ default = 0;
+ };
+
+ seabiosConfig = mkOption {
+ type = types.attrsOf (types.nullOr types.str);
+ default = {};
+ };
+ };
+
+ config = mkIf cfg.enable {
+ seabios.seabiosConfig = {
+ CONFIG_COREBOOT = "y";
+ } // (lib.optionalAttrs cfg.withVgaBios {
+ CONFIG_VGA_COREBOOT = "y";
+ CONFIG_BUILD_VGABIOS = "y";
+ });
+
+ corenix.extraFiles = let
+ package = pkgs.coreboot-payload-seabios.override {
+ inherit (cfg) seabiosConfig;
+ };
+ in {
+ ${payloadName} = {
+ type = "payload";
+ src = "${package}/bios.bin.elf";
+ };
+ } // (optionalAttrs cfg.withVgaBios {
+ "vgaroms/seavgabios.bin".src = "${package}/vgabios.bin";
+ });
+
+ corenix.installCommands = optionalString (cfg.ps2Timeout != 0) ''
+ cbfstool $out/coreboot.rom add-int \
+ -i ${toString cfg.ps2Timeout} \
+ -n etc/ps2-keyboard-spinup
+ '';
+ };
+}
diff --git a/pkgs/coreboot-payload-coreinfo/default.nix b/pkgs/coreboot-payload-coreinfo/default.nix
index 6513031330c5..21e00031166e 100644
--- a/pkgs/coreboot-payload-coreinfo/default.nix
+++ b/pkgs/coreboot-payload-coreinfo/default.nix
@@ -1,17 +1,18 @@
-{ coreboot, lib, stdenv, writeText, coreinfoConfig ? {}, ... }:
+{ coreboot
+, lib
+, stdenv
+, writeText
+, coreinfoConfig ? {}
+}:
-let
- filteredConfig = lib.filterAttrs (n: v: v != null) coreinfoConfig;
- lines = lib.mapAttrsToList (name: value: "${name}=${value}") filteredConfig;
- configFile = writeText "config" (lib.concatStringsSep "\n" lines);
-in stdenv.mkDerivation rec {
+stdenv.mkDerivation rec {
pname = "coreboot-payload-coreinfo";
inherit (coreboot.drvAttrs) version src postPatch;
preConfigure = "cd payloads/coreinfo";
configurePhase = ''
runHook preConfigure
- cp ${configFile} .config
+ cp ${coreboot.writeConfig coreinfoConfig} .config
make olddefconfig
runHook postConfigure
'';
diff --git a/pkgs/coreboot-payload-nvramcui/default.nix b/pkgs/coreboot-payload-nvramcui/default.nix
index 0c0eddfd5513..418f809960d7 100644
--- a/pkgs/coreboot-payload-nvramcui/default.nix
+++ b/pkgs/coreboot-payload-nvramcui/default.nix
@@ -1,4 +1,6 @@
-{ coreboot, stdenv, ... }:
+{ coreboot
+, stdenv
+}:
stdenv.mkDerivation rec {
pname = "coreboot-payload-nvramcui";
diff --git a/pkgs/coreboot-payload-seabios/default.nix b/pkgs/coreboot-payload-seabios/default.nix
new file mode 100644
index 000000000000..cd8b21559e7a
--- /dev/null
+++ b/pkgs/coreboot-payload-seabios/default.nix
@@ -0,0 +1,27 @@
+{ seabios
+, coreboot
+, stdenv
+, fetchurl
+, seabiosConfig ? { CONFIG_COREBOOT = "y"; CONFIG_VGA_COREBOOT = "y"; CONFIG_BUILD_VGABIOS = "y"; }
+}:
+
+seabios.overrideAttrs (oA: rec {
+ pname = "coreboot-payload-seabios";
+
+ version = "1.14.0";
+ src = fetchurl {
+ url = "https://www.seabios.org/downloads/seabios-${version}.tar.gz";
+ sha256 = "1zc1brgafbbf5hmdr1qc1p859cabpz73l8sklq83xa4sn9icqw7b";
+ };
+
+ configurePhase = ''
+ runHook preConfigure
+ cp ${coreboot.writeConfig seabiosConfig} .config
+ make olddefconfig
+ runHook postConfigure
+ '';
+ installPhase = ''
+ install -D out/bios.bin.elf -t $out
+ [ -f out/vgabios.bin ] && install -D out/vgabios.bin -t $out
+ '';
+})
diff --git a/pkgs/coreboot-payload-tianocore/default.nix b/pkgs/coreboot-payload-tianocore/default.nix
index 8d9c29dc5329..07e90a97d984 100644
--- a/pkgs/coreboot-payload-tianocore/default.nix
+++ b/pkgs/coreboot-payload-tianocore/default.nix
@@ -1,4 +1,13 @@
-{ fetchFromGitHub, python2, stdenv, libuuid, bc, utillinux, nasm, iasl, seabios }:
+{ 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
diff --git a/pkgs/coreboot-payload-tint/default.nix b/pkgs/coreboot-payload-tint/default.nix
index 4714f701cc30..a410a46a254d 100644
--- a/pkgs/coreboot-payload-tint/default.nix
+++ b/pkgs/coreboot-payload-tint/default.nix
@@ -1,4 +1,7 @@
-{ coreboot, stdenv, fetchurl, ... }:
+{ coreboot
+, stdenv
+, fetchurl
+}:
# the original tint does not support building as a coreboot payload
# the patches from the coreboot repo require building tint in-tree
diff --git a/pkgs/coreboot/default.nix b/pkgs/coreboot/default.nix
index 044e3667d650..3a24dd92fb54 100644
--- a/pkgs/coreboot/default.nix
+++ b/pkgs/coreboot/default.nix
@@ -44,9 +44,12 @@ let
'';
};
- filteredConfig = lib.filterAttrs (n: v: v != null) corebootConfig;
- lines = lib.mapAttrsToList (name: value: "${name}=${value}") filteredConfig;
- configFile = writeText "config" (lib.concatStringsSep "\n" lines);
+ 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";
@@ -61,7 +64,7 @@ in stdenv.mkDerivation rec {
configurePhase = ''
runHook preConfigure
- cp ${configFile} .config
+ cp ${writeConfig corebootConfig} .config
make olddefconfig
runHook postConfigure
'';
@@ -72,6 +75,6 @@ in stdenv.mkDerivation rec {
'';
passthru = {
- inherit toolchain configFile;
+ inherit toolchain writeConfig corebootConfig;
};
}
diff --git a/pkgs/overlay.nix b/pkgs/overlay.nix
index 780032ae1b6c..37af2f9e81ce 100644
--- a/pkgs/overlay.nix
+++ b/pkgs/overlay.nix
@@ -2,8 +2,13 @@ final: prev:
let inherit (final) callPackage;
in {
coreboot = callPackage ./coreboot {};
+
+ # primary payloads
coreboot-payload-grub2 = callPackage ./coreboot-payload-grub2 {};
coreboot-payload-tianocore = callPackage ./coreboot-payload-tianocore {};
+ coreboot-payload-seabios = callPackage ./coreboot-payload-seabios {};
+
+ # secondary payloads
coreboot-payload-nvramcui = callPackage ./coreboot-payload-nvramcui {};
coreboot-payload-tint = callPackage ./coreboot-payload-tint {};
coreboot-payload-coreinfo = callPackage ./coreboot-payload-coreinfo {};