diff options
author | Milan Pässler <milan@petabyte.dev> | 2020-10-11 21:06:30 +0200 |
---|---|---|
committer | Milan Pässler <milan@petabyte.dev> | 2020-10-12 12:27:12 +0200 |
commit | 53b6b4673d12b72519f5bc76f451305ac941b1b4 (patch) | |
tree | 7ea6b5e82a088a642cce31f0ca40e9bc4d06dd02 /modules | |
parent | b00e192187b0df94682712d5ba5a88c923a6b0ce (diff) |
add seabios
Diffstat (limited to 'modules')
-rw-r--r-- | modules/coreinfo/default.nix | 1 | ||||
-rw-r--r-- | modules/corenix/default.nix | 42 | ||||
-rw-r--r-- | modules/default.nix | 1 | ||||
-rw-r--r-- | modules/seabios/default.nix | 64 |
4 files changed, 90 insertions, 18 deletions
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 + ''; + }; +} |