nixos/netboot: Mount /boot via kernel command line

This commit is contained in:
Jack O'Sullivan 2024-06-29 23:41:01 +01:00
parent f9870abc9e
commit 19fb29213e
2 changed files with 37 additions and 0 deletions

View File

@ -71,6 +71,8 @@ in
};
};
networking = { inherit domain; };
services = {
lvm = {
boot.thin.enable = true;

View File

@ -56,6 +56,41 @@ in
config = mkMerge [
(mkIf cfg.client.enable {
systemd = {
services = {
mount-boot = {
description = "Mount /boot";
after = [ "systemd-networkd-wait-online.service" ];
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
};
path = with pkgs; [ gnused ldns nfs-utils ];
script = ''
get_cmdline() {
sed -rn "s/^.*$1=(\\S+).*\$/\\1/p" < /proc/cmdline
}
host="$(get_cmdline boothost)"
if [ -z "$host" ]; then
echo "boothost kernel parameter not found!" >&2
exit 1
fi
until [ -n "$(drill -Q $host)" ]; do
sleep 0.1
done
mkdir -p /boot
mount.nfs $host:/srv/netboot/systems/${config.system.name} /boot
'';
wantedBy = [ "remote-fs.target" ];
};
};
};
boot.supportedFilesystems.nfs = true;
boot.loader = {
grub.enable = false;
systemd-boot.enable = false;