2024-08-12 16:52:17 +01:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}: let
|
2024-08-12 16:54:39 +01:00
|
|
|
inherit (lib.modules) mkIf mkForce;
|
2024-08-12 16:52:17 +01:00
|
|
|
|
|
|
|
cfg = config.boot.encryptedDrive;
|
|
|
|
in {
|
|
|
|
config = mkIf (cfg.enable && cfg.mode == "ssh") {
|
|
|
|
boot.loader.supportsInitrdSecrets = true;
|
|
|
|
|
|
|
|
boot.initrd.secrets = {
|
|
|
|
# we only support ed25519 for now
|
|
|
|
"/ssh_host_ed25519_key" = mkForce "/initrd_ssh_host_ed25519_key";
|
|
|
|
};
|
|
|
|
|
|
|
|
boot.initrd.luks.forceLuksSupportInInitrd = true;
|
|
|
|
|
|
|
|
boot.initrd.network = {
|
|
|
|
enable = true;
|
|
|
|
ssh = {
|
|
|
|
enable = true;
|
|
|
|
port = 22;
|
|
|
|
authorizedKeys = config.users.users.root.openssh.authorizedKeys.keys;
|
|
|
|
hostKeys = ["/ssh_host_ed25519_key"];
|
|
|
|
};
|
|
|
|
postCommands = ''
|
|
|
|
echo 'cryptsetup-askpass' >> /root/.profile
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|