mirror of
https://github.com/CHN-beta/nixos.git
synced 2024-10-24 10:18:49 +08:00
34 lines
799 B
Nix
34 lines
799 B
Nix
inputs:
|
|
{
|
|
options.nixos.system.initrd = let inherit (inputs.lib) mkOption types; in
|
|
{
|
|
sshd =
|
|
{
|
|
enable = mkOption { type = types.bool; default = false; };
|
|
hostKeys = mkOption
|
|
{
|
|
type = types.listOf types.nonEmptyStr;
|
|
default = [ "/nix/persistent/etc/ssh/initrd_ssh_host_ed25519_key" ];
|
|
};
|
|
};
|
|
};
|
|
config =
|
|
let
|
|
inherit (inputs.config.nixos.system) initrd;
|
|
inherit (inputs.lib) mkIf mkMerge;
|
|
in mkMerge
|
|
[
|
|
{ boot.initrd.systemd.enable = true; }
|
|
(
|
|
mkIf (initrd.sshd.enable)
|
|
{
|
|
boot =
|
|
{
|
|
initrd.network = { enable = true; ssh = { enable = true; hostKeys = initrd.sshd.hostKeys; }; };
|
|
kernelParams = [ "ip=dhcp" ];
|
|
};
|
|
}
|
|
)
|
|
];
|
|
}
|