blob: 94698782f62e09f2a5449d1bb6fb52bac4ad7b8d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.corenix;
fileOptions.options = {
src = mkOption {
type = types.path;
};
type = mkOption {
type = types.str;
default = "raw";
};
};
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;
};
};
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;
};
in pkgs.runCommand "coreboot-rom" {
buildInputs = with pkgs; [ cbfstool ];
} ''
install -D ${base}/coreboot.rom -t $out
${cfg.installCommands}
'';
};
}
|