feat: support luks
This commit is contained in:
1 parent
5433f23513
commit
10eb2f7b98
4 files changed
+110
-6
No files matched your search
@@ -0,0 +1,52 @@
|
||||
{ bootvineModule }:
|
||||
{
|
||||
name = "bootvine-luks";
|
||||
enableOCR = true;
|
||||
|
||||
nodes.machine =
|
||||
{ lib, pkgs, ... }:
|
||||
{
|
||||
imports = [ bootvineModule ];
|
||||
|
||||
services.bootvine.enable = true;
|
||||
|
||||
boot.loader.systemd-boot.enable = true;
|
||||
boot.initrd.systemd.enable = true;
|
||||
environment.systemPackages = [ pkgs.cryptsetup ];
|
||||
|
||||
virtualisation = {
|
||||
emptyDiskImages = [ 64 ];
|
||||
useBootLoader = true;
|
||||
useEFIBoot = true;
|
||||
mountHostNixStore = true;
|
||||
};
|
||||
|
||||
specialisation.unlock.configuration = {
|
||||
boot.initrd.luks.devices = lib.mkVMOverride {
|
||||
secret.device = "/dev/vdb";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
passphrase = "quietly unlocked"
|
||||
|
||||
machine.wait_for_unit("multi-user.target")
|
||||
machine.succeed(f"echo -n '{passphrase}' | cryptsetup luksFormat -q --iter-time=1 /dev/vdb -")
|
||||
machine.succeed("bootctl set-default nixos-generation-1-specialisation-unlock.conf")
|
||||
machine.succeed("sync")
|
||||
machine.crash()
|
||||
|
||||
machine.start()
|
||||
machine.wait_for_text("passphrase")
|
||||
machine.screenshot("passphrase")
|
||||
machine.send_chars(f"{passphrase}\n")
|
||||
machine.wait_for_unit("multi-user.target")
|
||||
|
||||
machine.succeed("test -e /dev/mapper/secret")
|
||||
journal = machine.succeed("journalctl -b -u bootvine -o cat")
|
||||
print(journal)
|
||||
assert "in initrd" in journal, "never ran in the initrd"
|
||||
assert "taking the console back" in journal, "never took the console back after the prompt"
|
||||
'';
|
||||
}
|
||||
Reference in new issue
Block a user