2023-09-02 15:07:16 +08:00
|
|
|
inputs:
|
|
|
|
{
|
|
|
|
options.nixos.system.initrd = let inherit (inputs.lib) mkOption types; in
|
|
|
|
{
|
|
|
|
sshd =
|
|
|
|
{
|
|
|
|
enable = mkOption { type = types.bool; default = false; };
|
2023-11-19 17:29:15 +08:00
|
|
|
hostKeys = mkOption
|
|
|
|
{
|
|
|
|
type = types.listOf types.nonEmptyStr;
|
|
|
|
default = [ "/nix/persistent/etc/ssh/initrd_ssh_host_ed25519_key" ];
|
|
|
|
};
|
2023-09-02 15:07:16 +08:00
|
|
|
};
|
|
|
|
};
|
2024-07-03 09:58:40 +08:00
|
|
|
config = let inherit (inputs.config.nixos.system) initrd; in inputs.lib.mkMerge
|
|
|
|
[
|
2024-07-03 10:42:15 +08:00
|
|
|
{
|
|
|
|
boot =
|
|
|
|
{
|
|
|
|
initrd.systemd.enable = true;
|
|
|
|
kernelParams = [ "boot.shell_on_fail" "systemd.setenv=SYSTEMD_SULOGIN_FORCE=1" ];
|
|
|
|
};
|
|
|
|
}
|
2024-07-03 09:58:40 +08:00
|
|
|
(
|
|
|
|
inputs.lib.mkIf (initrd.sshd.enable)
|
|
|
|
{
|
|
|
|
boot =
|
2023-11-19 17:29:15 +08:00
|
|
|
{
|
2024-07-04 11:02:47 +08:00
|
|
|
initrd =
|
|
|
|
{
|
|
|
|
network = { enable = true; ssh = { enable = true; hostKeys = initrd.sshd.hostKeys; }; };
|
|
|
|
# resolved does not work in initrd, causing network.target to fail
|
|
|
|
services.resolved.enable = false;
|
|
|
|
};
|
2024-07-03 10:42:15 +08:00
|
|
|
kernelParams = [ "ip=dhcp" ];
|
2024-07-03 09:58:40 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
)
|
|
|
|
];
|
2023-09-02 15:07:16 +08:00
|
|
|
}
|