···
server = { config, pkgs, ... }: {
7
-
environment.systemPackages = [ pkgs.cryptsetup ];
8
-
boot.loader.systemd-boot.enable = true;
9
-
boot.loader.timeout = 0;
11
-
emptyDiskImages = [ 4096 ];
12
-
useBootLoader = true;
13
-
# Booting off the encrypted disk requires an available init script from
15
-
mountHostNixStore = true;
19
-
specialisation.encrypted-root.configuration = {
20
-
virtualisation.rootDevice = "/dev/mapper/root";
21
-
virtualisation.fileSystems."/".autoFormat = true;
22
-
boot.initrd.luks.devices = lib.mkVMOverride {
23
-
root.device = "/dev/vdb";
25
-
boot.initrd.systemd.enable = true;
26
-
boot.initrd.network = {
7
+
testing.initrdBackdoor = true;
8
+
boot.initrd.systemd.enable = true;
9
+
boot.initrd.systemd.contents."/etc/msg".text = "foo";
10
+
boot.initrd.network = {
30
-
authorizedKeys = [ (lib.readFile ./initrd-network-ssh/id_ed25519.pub) ];
32
-
# Terrible hack so it works with useBootLoader
33
-
hostKeys = [ { outPath = "${./initrd-network-ssh/ssh_host_ed25519_key}"; } ];
14
+
authorizedKeys = [ (lib.readFile ./initrd-network-ssh/id_ed25519.pub) ];
16
+
hostKeys = [ ./initrd-network-ssh/ssh_host_ed25519_key ];
···
status, _ = client.execute("nc -z server 22")
66
-
server.wait_for_unit("multi-user.target")
68
-
"echo somepass | cryptsetup luksFormat --type=luks2 /dev/vdb",
69
-
"bootctl set-default nixos-generation-1-specialisation-encrypted-root.conf",
client.wait_for_unit("network.target")
with client.nested("waiting for SSH server to come up"):
80
-
"echo somepass | ssh -i /etc/sshKey -o UserKnownHostsFile=/etc/knownHosts server 'systemd-tty-ask-password-agent' & exit"
52
+
msg = client.succeed(
53
+
"ssh -i /etc/sshKey -o UserKnownHostsFile=/etc/knownHosts server 'cat /etc/msg'"
57
+
server.switch_root()
server.wait_for_unit("multi-user.target")
84
-
server.succeed("mount | grep '/dev/mapper/root on /'")