Last active
December 29, 2016 23:08
-
-
Save lheckemann/78e4cb38ae3cc280b6d89f8f13e7727f to your computer and use it in GitHub Desktop.
PXE boot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nix-build && sudo dnsmasq -c result/dnsmasq.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ system ? builtins.currentSystem }: | |
let | |
pkgs = import <nixpkgs> {}; | |
netboot = (import <nixpkgs/nixos/release.nix> {}).netboot.x86_64-linux; | |
grubConfig = pkgs.writeText "grub.cfg" '' | |
set timeout=5 | |
menuentry "NixOS Installer" { | |
echo "Loading kernel..." | |
linux (pxe)/installer/bzImage @kernelOpts@ | |
echo "Loading initramfs..." | |
initrd (pxe)/installer/initrd | |
echo "Booting..." | |
} | |
''; | |
grub = pkgs.runCommand "grub" { | |
buildInputs = [ pkgs.grub2 pkgs.perlPackages.perl ]; | |
} '' | |
mkdir $out | |
export kernelOpts="$(perl -ne '/.*bzImage (.*)/ && print $1' ${netboot}/netboot.ipxe)" | |
echo "KERNEL OPTIONS: $kernelOpts" | |
substituteAll ${grubConfig} $out/grub.cfg | |
grub-mkimage --format=i386-pc-pxe -o $out/grub.pxe --prefix='(pxe)/boot' pxe net tftp normal echo linux | |
ln -s ${pkgs.grub2}/lib/grub/i386-pc $out/ | |
''; | |
in | |
pkgs.runCommand "tftproot" { | |
} '' | |
mkdir -p $out | |
substituteAll ${./dnsmasq.conf} $out/dnsmasq.conf | |
ln -s ${grub} $out/boot | |
ln -s ${netboot} $out/installer | |
'' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface=enp2s0f0 | |
keep-in-foreground | |
dhcp-range=10.123.0.10,10.123.0.200,6h | |
dhcp-boot=boot/grub.pxe | |
enable-tftp | |
tftp-root=@out@ | |
dhcp-option=3 | |
dhcp-option=6 | |
port=0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment