-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathairgap-boot.nix
277 lines (241 loc) · 7.55 KB
/
airgap-boot.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
{
lib,
modulesPath,
pkgs,
self,
system,
...
}: let
inherit
(self.imageParameters)
embedFlakeDeps
etcFlakePath
hostId
hostName
documentsDir
secretsDir
airgapUser
airgapUserUid
airgapUserGroup
prodImage
;
in {
imports = [(modulesPath + "/installer/cd-dvd/installation-cd-graphical-gnome.nix")];
boot = {
initrd.availableKernelModules = [
# Support for various usb hubs
"ohci_pci"
"ohci_hcd"
"ehci_pci"
"ehci_hcd"
"xhci_pci"
"xhci_hcd"
# May be needed in some situations
"uas"
# Needed to mount usb as a storage device
"usb-storage"
];
kernelModules = ["kvm-intel"];
supportedFilesystems = ["zfs"];
# To address build time warn
swraid.enable = lib.mkForce false;
};
documentation.info.enable = false;
environment = {
etc = {
# Embed this flake source in the iso to re-use the disko or other configuration
${etcFlakePath}.source = self.outPath;
"signing-tool-config.json".source = builtins.toFile "signing-tool-config.json" (builtins.toJSON {
inherit documentsDir secretsDir;
});
};
systemPackages = with self.packages.${system};
[
bech32
cardano-address
cardano-cli
disko
format-airgap-data
menu
orchestrator-cli
signing-tool
signing-tool-with-config
unmount-airgap-data
shutdown
]
++ (with pkgs; [
cfssl
cryptsetup
glibc
gnome3.adwaita-icon-theme
gnupg
jq
lvm2
neovim
openssl
pwgen
smem
sqlite-interactive
step-cli
usbutils
util-linux
]);
variables = {
ENC_DIR = secretsDir;
PUB_DIR = documentsDir;
};
};
# Used by starship for fonts
fonts.packages = with pkgs; [
(nerdfonts.override {fonts = ["FiraCode"];})
];
# Disable squashfs for testing only
# Set the flake.nix `imageParameters.prodImage = true;` when ready to build the distribution image to use image compression
isoImage.squashfsCompression = lib.mkIf (!prodImage) ((lib.warn "Generating a testing only ISO with compression disabled") null);
nix = {
extraOptions = ''
experimental-features = nix-command flakes
accept-flake-config = true
'';
nixPath = ["nixpkgs=${pkgs.path}"];
settings = {
substituters = lib.mkForce [];
trusted-users = [airgapUser];
};
};
nixpkgs.config.allowUnfree = true;
networking = {
inherit hostId hostName;
enableIPv6 = lib.mkForce false;
interfaces = lib.mkForce {};
networkmanager.enable = lib.mkForce false;
useDHCP = lib.mkForce false;
wireless.enable = lib.mkForce false;
};
programs = {
bash = {
enableCompletion = true;
interactiveShellInit = lib.getExe self.packages.${system}.menu;
};
fzf = {
fuzzyCompletion = true;
keybindings = true;
};
starship = {
enable = true;
settings = {
git_commit = {
tag_disabled = false;
only_detached = false;
};
git_metrics = {
disabled = false;
};
memory_usage = {
disabled = false;
format = "via $symbol[\${ram_pct}]($style) ";
threshold = -1;
};
shlvl = {
disabled = false;
symbol = "↕";
threshold = -1;
};
status = {
disabled = false;
map_symbol = true;
pipestatus = true;
};
time = {
disabled = false;
format = "[\\[ $time \\]]($style) ";
};
};
};
dconf.enable = true;
gnupg.agent.enable = true;
};
services = {
displayManager.autoLogin.user = lib.mkForce airgapUser;
udev.extraRules = ''
SUBSYSTEMS=="usb", ATTRS{idVendor}=="2581", ATTRS{idProduct}=="1b7c", MODE="0660", TAG+="uaccess", TAG+="udev-acl"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="2581", ATTRS{idProduct}=="2b7c", MODE="0660", TAG+="uaccess", TAG+="udev-acl"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="2581", ATTRS{idProduct}=="3b7c", MODE="0660", TAG+="uaccess", TAG+="udev-acl"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="2581", ATTRS{idProduct}=="4b7c", MODE="0660", TAG+="uaccess", TAG+="udev-acl"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="2581", ATTRS{idProduct}=="1807", MODE="0660", TAG+="uaccess", TAG+="udev-acl"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="2581", ATTRS{idProduct}=="1808", MODE="0660", TAG+="uaccess", TAG+="udev-acl"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="2c97", ATTRS{idProduct}=="0000", MODE="0660", TAG+="uaccess", TAG+="udev-acl"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="2c97", ATTRS{idProduct}=="0001", MODE="0660", TAG+="uaccess", TAG+="udev-acl"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="2c97", ATTRS{idProduct}=="0004", MODE="0660", TAG+="uaccess", TAG+="udev-acl"
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", MODE="0660", GROUP="plugdev", ATTRS{idVendor}=="2c97"
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", MODE="0660", GROUP="plugdev", ATTRS{idVendor}=="2581"
ACTION=="add", SUBSYSTEM=="thunderbolt", ATTR{authorized}=="0", ATTR{authorized}="1"
'';
};
systemd.user.services.dconf-defaults = {
script = let
dconfDefaults = pkgs.writeText "dconf.defaults" ''
[org/gnome/desktop/background]
color-shading-type='solid'
picture-options='zoom'
picture-uri='${./cardano.png}'
primary-color='#000000000000'
secondary-color='#000000000000'
[org/gnome/desktop/lockdown]
disable-lock-screen=true
disable-log-out=true
disable-user-switching=true
[org/gnome/desktop/notifications]
show-in-lock-screen=false
[org/gnome/desktop/screensaver]
color-shading-type='solid'
lock-delay=uint32 0
lock-enabled=false
picture-options='zoom'
picture-uri='${./cardano.png}'
primary-color='#000000000000'
secondary-color='#000000000000'
[org/gnome/settings-daemon/plugins/media-keys]
custom-keybindings=['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/']
[org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0]
binding='<Primary><Alt>t'
command='kgx'
name='console'
[org/gnome/settings-daemon/plugins/power]
idle-dim=false
power-button-action='interactive'
sleep-inactive-ac-type='nothing'
[org/gnome/shell]
welcome-dialog-last-shown-version='41.2'
'';
in ''
${pkgs.dconf}/bin/dconf load / < ${dconfDefaults}
'';
wantedBy = ["graphical-session.target"];
partOf = ["graphical-session.target"];
};
users = {
allowNoPasswordLogin = true;
defaultUserShell = pkgs.bash;
mutableUsers = false;
users.${airgapUser} = {
createHome = true;
extraGroups = ["wheel"];
group = airgapUserGroup;
home = "/home/${airgapUser}";
uid = airgapUserUid;
isNormalUser = true;
};
};
system = {
# This works to enable flake based disko builds within the image,
# but adds significant eval time and size for image generation.
#
# Alternatively, the disko builds can be done using the
# airgap-disko.nix configuration from within the image without
# requiring the flake closure dependencies.
extraDependencies = lib.mkIf embedFlakeDeps [(self.packages.${system}.flakeClosureRef self)];
# To address build time warn
stateVersion = lib.versions.majorMinor lib.version;
};
}