-
-
Save cleverca22/75e3db4dabeff05b743e9be77a2341b9 to your computer and use it in GitHub Desktop.
justdoit
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
<?php | |
switch (strtolower($_GET['mac'])) { | |
case '00:1c:23:16:4b:b3'; | |
?> | |
#!ipxe | |
sanboot iscsi:192.168.2.11:::1:iqn.2016-01.laptop-root | |
<?php | |
break; | |
default; | |
case '08:00:27:15:bd:7b'; | |
case '08:00:27:1f:4d:5a'; | |
if ($_GET['version'] == '') { | |
?> | |
#!ipxe | |
chain tftp://192.168.2.61/undionly.kpxe | |
<?php | |
} else { | |
?> | |
#!ipxe | |
chain http://c2d.localnet/netboot/netboot.ipxe | |
<?php | |
} | |
break; | |
} |
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
{ pkgs, ... }: | |
let | |
justdoit = pkgs.writeScriptBin "justdoit" '' | |
#!${pkgs.stdenv.shell} | |
dd if=/dev/zero of=/dev/sda bs=512 count=10000 | |
sfdisk /dev/sda <<EOF | |
label: dos | |
device: /dev/sda | |
unit: sectors | |
/dev/sda1 : start= 2048, size=3145728, type=83 | |
EOF | |
mkfs.ext4 /dev/sda1 | |
mount -v /dev/sda1 /mnt | |
nixos-generate-config --root /mnt | |
cp -v ${./target-config.nix} /mnt/etc/nixos/configuration.nix | |
nixos-install -j 4 | |
umount /mnt | |
''; | |
in { | |
imports = [ <nixpkgs/nixos/modules/installer/netboot/netboot-minimal.nix> ]; | |
environment.systemPackages = [ justdoit ]; | |
} |
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
subnet 192.168.2.0 netmask 255.255.255.0 { | |
option domain-search "localnet"; | |
option subnet-mask 255.255.255.0; | |
option broadcast-address 192.168.2.255; | |
option routers 192.168.2.1; | |
option domain-name-servers 192.168.2.1, 8.8.8.8, 8.8.4.4; | |
range 192.168.2.100 192.168.2.200; | |
next-server 192.168.2.61; | |
if exists user-class and option user-class = "iPXE" { | |
filename "http://c2d.localnet/boot.php?mac=${net0/mac}&asset=${asset:uristring}&version=${builtin/version}"; | |
} else { | |
filename = "undionly.kpxe"; | |
} | |
} |
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
clever@c2d /var/www/c2d $ nix-build netboot.nix -o netboot |
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
let | |
pkgs = import <nixpkgs> {}; | |
build = (import <nixpkgs/nixos> { configuration = ./configuration.nix; }).config.system.build; | |
in | |
pkgs.symlinkJoin { | |
name="netboot"; | |
paths=[ | |
build.netbootRamdisk | |
build.kernel | |
build.netbootIpxeScript | |
]; | |
} |
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
{ config, pkgs, ... }: | |
{ | |
imports = [ ./hardware-configuration.nix ]; | |
boot.loader.grub.enable = true; | |
boot.loader.grub.version = 2; | |
boot.loader.grub.device = "/dev/sda"; | |
networking.hostName = "autoinstall"; | |
users.users.root.initialPassword = "root"; | |
users.mutableUsers = false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment