2024-08-07 11:07:10 +02:00
|
|
|
{ config, lib, pkgs, factsGenerator, clanLib, ... }:
|
|
|
|
with lib;
|
|
|
|
with types;
|
|
|
|
|
|
|
|
{
|
2024-08-08 16:39:50 +02:00
|
|
|
options.features.boot.ssh = {
|
2024-08-07 11:07:10 +02:00
|
|
|
enable = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
2024-08-08 16:39:50 +02:00
|
|
|
default = false;
|
2024-08-07 11:07:10 +02:00
|
|
|
};
|
|
|
|
kernelModules = mkOption {
|
|
|
|
type = listOf str;
|
|
|
|
default = [ ];
|
|
|
|
description =
|
|
|
|
"nix-shell -p pciutils --run 'lspci -v' will tell you which kernel module is used for the ethernet interface";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-08-08 16:39:50 +02:00
|
|
|
config = mkIf (config.features.boot.ssh.enable) {
|
2024-08-07 11:07:10 +02:00
|
|
|
|
|
|
|
# ssh host key
|
|
|
|
clan.core.facts.services."boot.ssh" = factsGenerator.ssh { name = "boot"; };
|
|
|
|
|
|
|
|
# boot
|
|
|
|
boot.initrd.systemd.enable = true;
|
|
|
|
boot.initrd.systemd.contents."/etc/hostname".text = "unlock.${config.networking.hostName}";
|
|
|
|
|
|
|
|
# network
|
|
|
|
boot.initrd.systemd.network.enable = true;
|
2024-08-08 16:39:50 +02:00
|
|
|
boot.initrd.availableKernelModules = config.features.boot.ssh.kernelModules;
|
2024-08-07 11:07:10 +02:00
|
|
|
|
|
|
|
# ssh
|
|
|
|
boot.initrd.network.enable = true;
|
|
|
|
boot.initrd.network.ssh = {
|
|
|
|
enable = true;
|
|
|
|
authorizedKeys = config.users.users.root.openssh.authorizedKeys.keys;
|
|
|
|
port = 2222;
|
|
|
|
hostKeys = [ config.clan.core.facts.services."boot.ssh".secret."ssh.boot.id_ed25519".path ];
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|