2022-03-16 23:16:02 +01:00
|
|
|
{ tftproots, hostRegistry, lib, pkgs, ... }:
|
2022-03-16 20:38:00 +01:00
|
|
|
let
|
2022-08-22 22:14:16 +02:00
|
|
|
netbootxyzVersion = "2.0.60";
|
|
|
|
netbootxyz_efi = pkgs.fetchurl {
|
|
|
|
url = "https://github.com/netbootxyz/netboot.xyz/releases/download/${netbootxyzVersion}/netboot.xyz.efi";
|
|
|
|
sha256 = "1k9i81iw6lhs1h8qy8yapasqcl31yxl2jxn52ls5anvm477650qk";
|
|
|
|
};
|
|
|
|
netbootxyz_kpxe = pkgs.fetchurl {
|
|
|
|
url = "https://github.com/netbootxyz/netboot.xyz/releases/download/${netbootxyzVersion}/netboot.xyz.kpxe";
|
|
|
|
sha256 = "1jr8qwkkj3ccvhdw98fakj07md0nkswy2mlg1rdhcnqzhas7qbj3";
|
|
|
|
};
|
2022-03-16 23:16:02 +01:00
|
|
|
tftpRoot = pkgs.runCommand "tftproot" {} ''
|
|
|
|
mkdir $out
|
2022-06-10 19:01:14 +02:00
|
|
|
|
2022-08-22 22:14:16 +02:00
|
|
|
# PXE for PC
|
|
|
|
ln -s ${netbootxyz_efi} $out/netboot.xyz.efi
|
|
|
|
ln -s ${netbootxyz_kpxe} $out/netboot.xyz.kpxe
|
|
|
|
|
|
|
|
# generic boot files for pis
|
2022-03-17 00:21:04 +01:00
|
|
|
cp -sr ${tftproots.rpi-netboot-tftproot}/* $out/
|
2022-08-22 22:14:16 +02:00
|
|
|
|
|
|
|
# dacbert
|
|
|
|
ln -s /var/lib/nfsroot/dacbert/boot $out/${hostRegistry.hosts.dacbert.serial}
|
|
|
|
|
|
|
|
# boot files for specific pis by serial number subdirectories
|
2022-03-16 23:16:02 +01:00
|
|
|
${lib.concatMapStrings (host: ''
|
2022-08-22 22:14:16 +02:00
|
|
|
if ! [ -L $out/${hostRegistry.hosts.${host}.serial} ]; then
|
|
|
|
ln -s ${tftproots."${host}-tftproot"} $out/${hostRegistry.hosts.${host}.serial}
|
|
|
|
fi
|
2022-03-16 23:16:02 +01:00
|
|
|
'') (
|
|
|
|
builtins.attrNames (
|
2022-03-17 00:21:04 +01:00
|
|
|
lib.filterAttrs (_: { serial ? null, ... }: serial != null)
|
|
|
|
hostRegistry.hosts
|
2022-03-16 23:16:02 +01:00
|
|
|
)
|
|
|
|
)}
|
|
|
|
'';
|
2022-03-16 20:38:00 +01:00
|
|
|
in
|
|
|
|
{
|
|
|
|
networking.firewall.enable = false;
|
|
|
|
|
|
|
|
# raspberrypi boot
|
|
|
|
services.atftpd = {
|
|
|
|
enable = true;
|
|
|
|
root = tftpRoot;
|
|
|
|
};
|
|
|
|
}
|