From 19ac914c4ec5a40165c50ed9d41f7490a2383fa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milan=20P=C3=A4ssler?= Date: Sat, 10 Oct 2020 16:57:52 +0200 Subject: . --- modules/coreboot/default.nix | 44 ++++++++++++++++++++++++++++++++++++++++++++ modules/default.nix | 9 +++++++++ modules/grub2/default.nix | 20 ++++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 modules/coreboot/default.nix create mode 100644 modules/default.nix create mode 100644 modules/grub2/default.nix (limited to 'modules') 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"; + }; + }; + }; +} -- cgit v1.2.3