forked from Tow-Boot/Tow-Boot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocumentation.nix
133 lines (105 loc) · 3.65 KB
/
documentation.nix
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
{ config, lib, pkgs, ... }:
let
inherit (lib)
mkOption
optionalString
types
;
inherit (config.device)
identifier
;
withMMCBoot = config.hardware.mmcBootIndex != null;
withSPI = config.hardware.SPISize != null;
withDedicatedStorage = withSPI || withMMCBoot;
inherit (config) device;
fullName = "${device.manufacturer} ${device.name}";
in
{
options = {
documentation = {
helpers = {
genericInstallationInstructionsTemplate = mkOption {
type = types.unspecified;
internal = true;
description = ''
Function that returns a markdown snippet with generic installation
instructions.
'';
};
genericSharedStorageInstructionsTemplate = mkOption {
type = types.unspecified;
internal = true;
description = ''
Function that returns a markdown snippet with generic shared
storage strategy instructions.
'';
};
};
sections = {
installationInstructions = mkOption {
type = types.str;
internal = true;
description = ''
Markdown fragment with device installation instructions.
'';
};
};
};
};
config = {
documentation.helpers.genericSharedStorageInstructionsTemplate =
{ storage ? "an SD card or eMMC" }:
''
### Installing to shared storage
Using the shared storage strategy on the *${fullName}* can be done by
writing the `shared.disk-image.img` to ${storage}.
```
# dd if=shared.disk-image.img of=/dev/XXX bs=1M oflag=direct,sync status=progress
```
''
;
documentation.helpers.genericInstallationInstructionsTemplate =
{ storage ? "an SD card"
, startupConflictNote
}:
''
## Installation instructions
${optionalString withSPI ''
### Installing to SPI (recommended)
${startupConflictNote}
By installing Tow-Boot to SPI, your *${fullName}* will be able to
start using standards-based booting without conflicting with the
operating system storage.
To do so, you will need to write the SPI installer image to ${storage}.
```
# dd if=spi.installer.img of=/dev/XXX bs=1M oflag=direct,sync status=progress
```
Once done, start the system, and in the boot menu, select
*“Flash firmware to SPI”*.
Once this is done, remove the installation media, and verify Tow-Boot
starts from power-on.
''}
${optionalString withMMCBoot ''
### Installing to eMMC Boot${optionalString (!withSPI) " (recommended)"}
${startupConflictNote}
By installing Tow-Boot to eMMC Boot, your *${fullName}* will be able to
start using standards-based booting without conflicting with the
operating system storage.
To do so, you will need to write the eMMC Boot installer image to ${storage}.
```
# dd if=mmcboot.installer.img of=/dev/XXX bs=1M oflag=direct,sync status=progress
```
Once done, start the system, and in the boot menu, select
*“Flash firmware to eMMC Boot”*.
Once this is done, remove the installation media, and verify Tow-Boot
starts from power-on.
''}
${config.documentation.helpers.genericSharedStorageInstructionsTemplate {}}
''
;
documentation.sections.installationInstructions =
lib.mkOptionDefault
(builtins.throw "${identifier} missing installationInstructions...")
;
};
}