surgat: add sshd to initrd

This commit is contained in:
Tim Schubert 2023-02-04 17:54:21 +01:00
parent f252b99469
commit 9c27dbc6c3
Signed by: dadada
GPG key ID: EEB8D1CE62C4DFEA
5 changed files with 38 additions and 1 deletions

View file

@ -0,0 +1,34 @@
{ config, lib, ... }:
let
secretsPath = config.dadada.secrets.path;
initrdHostKey = "${config.networking.hostName}-ssh_host_ed25519_key";
in
{
boot.initrd.availableKernelModules = [ "virtio-pci" ];
boot.initrd.network = {
enable = true;
ssh = {
enable = true;
port = 43235;
hostKeys = [
age.secrets."${initrdHostKey}"
];
authorizedKeys = with lib;
concatLists (mapAttrsToList
(name: user:
if elem "wheel" user.extraGroups then
user.openssh.authorizedKeys.keys
else
[ ])
config.users.users);
};
postCommands = ''
echo 'cryptsetup-askpass' >> /root/.profile
'';
};
age.secrets."${initrdHostKey}" = {
file = "${secretsPath}/${initrdHostKey}";
mode = "600";
};
}

View file

@ -26,7 +26,7 @@ with lib; {
system.autoUpgrade = {
enable = true;
flake = "github:dadada/nix-config#${config.networking.hostName}";
allowReboot = true;
allowReboot = mkDefault true;
randomizedDelaySec = "45min";
};