Created
May 23, 2019 21:18
-
-
Save r2r-dev/f29dbf447510681e4fbc0037f8c1051c to your computer and use it in GitHub Desktop.
netboot+iso
This file contains hidden or 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, lib }: let | |
system = import <nixpkgs/nixos/lib/eval-config.nix> { | |
modules = [{ | |
imports = [ | |
<nixpkgs/nixos/modules/installer/cd-dvd/installation-cd-base.nix> | |
]; | |
boot.initrd.network.enable = true; | |
boot.devSize = "500m"; | |
boot.initrd.kernelModules = [ "e1000" ]; | |
boot.initrd.extraUtilsCommands ='' | |
cp ${pkgs.stdenv.cc.libc}/lib/libnss_dns.so.* $out/lib/ | |
''; | |
boot.initrd.network.postCommands = '' | |
wget 'https://d3g5gsiof5omrk.cloudfront.net/nixos/18.09/nixos-18.09.1922.97e0d53d669/nixos-minimal-18.09.1922.97e0d53d669-x86_64-linux.iso' -O /dev/root | |
''; | |
boot.initrd.postMountCommands = '' | |
export stage2Init=$(awk '/APPEND/ {for(i=1;i<=NF;i++){ if($i ~ /init/){split($2,a,"="); print a[2]; exit} } }' /mnt-root/iso/isolinux/isolinux.cfg) | |
''; | |
}]; | |
}; | |
in pkgs.writeScript "run" '' | |
#!/bin/sh | |
${pkgs.kvm}/bin/qemu-kvm -m 2G \ | |
-kernel ${system.config.system.build.kernel}/bzImage \ | |
-initrd ${system.config.system.build.initialRamdisk}/initrd \ | |
-net nic,netdev=user.0,model=e1000 -netdev user,id=user.0,hostfwd=tcp::8022-:22 \ | |
-append "console=ttyS0 copytoram" -nographic | |
'' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment