diff options
Diffstat (limited to 'modules/corenix/default.nix')
-rw-r--r-- | modules/corenix/default.nix | 42 |
1 files changed, 24 insertions, 18 deletions
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} ''; }; } |