aboutsummaryrefslogtreecommitdiff
path: root/modules/seabios
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 /modules/seabios
parentb00e192187b0df94682712d5ba5a88c923a6b0ce (diff)
add seabios
Diffstat (limited to 'modules/seabios')
-rw-r--r--modules/seabios/default.nix64
1 files changed, 64 insertions, 0 deletions
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
+ '';
+ };
+}