Nix-Config/hosts/apollo/boot.nix
2026-10-01 19:43:53 -05:00

90 lines
No EOL
2 KiB
Nix

{ pkgs, lib, inputs, ... }:
{
boot.initrd = {
supportedFilesystems = [ "ext4" "zfs" ];
systemd = {
enable = true;
fido2.enable = true;
emergencyAccess = true;
mounts = [
{
what = "/dev/mapper/zfs-keys";
where = "/keys";
type = "ext4";
options = "ro";
}
];
};
luks.fido2Support = false;
luks.devices."zfs-keys" = {
device = "/dev/disk/by-id/nvme-CT1000P2SSD8_2138E5D5DA5A-part2";
crypttabExtraOpts = [ "fido2-device=auto" ];
};
systemd.services."zfs-import-nix-root" = {
wants = [ "keys.mount" ];
after = [ "keys.mount" ];
};
network = {
enable = true;
ssh = {
enable = true;
port = 2222;
hostKeys = [ "/etc/secrets/initrd/ssh_host_ed25519_key" ];
# Use an inline string to prepend the forced systemd command to your key
authorizedKeys = [
''command="${pkgs.systemd}/bin/systemd-tty-ask-password-agent --watch" ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIjed9TzAaS6afEilS6CQAyz7DRJUNeLWGeboB3Ma3Rb remote-fido-unlock''
];
};
};
};
systemd.services."zfs-import-nix-main" = {
wants = [ "keys.mount" ];
after = [ "keys.mount" ];
};
boot.zfs.forceImportRoot = false;
fileSystems."/" = {
device = "nix-root/root";
fsType = "zfs";
};
fileSystems."/var/log" = {
device = "nix-root/syslog";
fsType = "zfs";
};
fileSystems."/nix" = {
device = "nix-root/nix";
fsType = "zfs";
};
fileSystems."/keys" = {
device = "/dev/mapper/zfs-keys";
fsType = "ext4";
};
fileSystems."/home/nyxerinys" = {
device = "nix-main/nyxerinys";
fsType = "zfs";
};
fileSystems."/boot" = {
device = "/dev/disk/by-uuid/A5CB-B201";
fsType = "vfat";
options = [ "fmask=0022" "dmask=0022" ];
};
swapDevices = [
{
device = "/dev/disk/by-id/nvme-CT1000P2SSD8_2138E5D5DA5A-part3";
randomEncryption.enable = true;
}
];
}