mirror of
https://github.com/Stunkymonkey/nixos.git
synced 2026-04-27 07:48:44 +02:00
service/initrd-ssh: support systemd-boot
Some checks failed
/ Build Nix targets (push) Has been cancelled
Some checks failed
/ Build Nix targets (push) Has been cancelled
This commit is contained in:
parent
7909067dc7
commit
aedea1d68a
2 changed files with 42 additions and 12 deletions
|
|
@ -109,6 +109,7 @@ in
|
||||||
};
|
};
|
||||||
initrd-ssh = {
|
initrd-ssh = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
mode = "grub2";
|
||||||
};
|
};
|
||||||
# self-hosted recipe manager
|
# self-hosted recipe manager
|
||||||
tandoor-recipes = {
|
tandoor-recipes = {
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,23 @@ in
|
||||||
{
|
{
|
||||||
options.my.services.initrd-ssh = {
|
options.my.services.initrd-ssh = {
|
||||||
enable = lib.mkEnableOption "Enable initrd-ssh service";
|
enable = lib.mkEnableOption "Enable initrd-ssh service";
|
||||||
|
|
||||||
|
mode = lib.mkOption {
|
||||||
|
type = lib.types.enum [
|
||||||
|
"grub2"
|
||||||
|
"systemd"
|
||||||
|
];
|
||||||
|
default = "systemd";
|
||||||
|
description = "Whether to use GRUB2 or systemd for the initrd SSH server.";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
boot.initrd.network = {
|
boot.initrd = {
|
||||||
|
secrets = {
|
||||||
|
"/etc/secrets/initrd/ssh_host_ed25519_key" = "/etc/secrets/initrd/ssh_host_ed25519_key";
|
||||||
|
};
|
||||||
|
network = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
ssh = {
|
ssh = {
|
||||||
|
|
@ -21,9 +34,25 @@ in
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
postCommands = ''
|
postCommands = lib.optionalString (cfg.mode == "grub2") ''
|
||||||
echo 'cryptsetup-askpass' >> /root/.profile
|
echo 'cryptsetup-askpass || echo "Unlock was successful; exiting SSH session" && exit 1' >> /root/.profile
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd = lib.optionalAttrs (cfg.mode == "systemd") {
|
||||||
|
enable = true;
|
||||||
|
network.enable = true;
|
||||||
|
services.luks-remote-unlock = {
|
||||||
|
description = "Prepare for LUKS remote unlock";
|
||||||
|
wantedBy = [ "initrd.target" ];
|
||||||
|
after = [ "systemd-networkd.service" ];
|
||||||
|
unitConfig.DefaultDependencies = "no";
|
||||||
|
serviceConfig.Type = "oneshot";
|
||||||
|
script = ''
|
||||||
|
echo 'systemctl default || echo "Unlock was successful; exiting SSH session" && exit 1' >> /var/empty/.profile
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue