aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorMilan Pässler <milan@petabyte.dev>2020-10-10 16:57:52 +0200
committerMilan Pässler <milan@petabyte.dev>2020-10-10 16:57:52 +0200
commit19ac914c4ec5a40165c50ed9d41f7490a2383fa4 (patch)
tree99bf23701df2016e5fc391ea8de3436c86d8ea6a /modules
parent38ab1843819e461543749c8a849a2d876ed6002e (diff)
.
Diffstat (limited to 'modules')
-rw-r--r--modules/coreboot/default.nix44
-rw-r--r--modules/default.nix9
-rw-r--r--modules/grub2/default.nix20
3 files changed, 73 insertions, 0 deletions
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";
+ };
+ };
+ };
+}