diff --git a/pkgs/default.nix b/pkgs/default.nix index e4e982f..226faac 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -8,6 +8,8 @@ nix = nixUnstable; }; + makePxeScript = callPackage ./pxescript {}; + makeSquashfsManifest = callPackage ./squashfs-recursive { # nixUnstable may not be required. Todo: revisit (2020-05-25) nix = nixUnstable; diff --git a/pkgs/pxescript/default.nix b/pkgs/pxescript/default.nix new file mode 100644 index 0000000..ee55308 --- /dev/null +++ b/pkgs/pxescript/default.nix @@ -0,0 +1,39 @@ +{ stdenv, runCommand }: +{ config +, initrds ? {} +, pkgs +, +}: +runCommand "netboot" { + pxe = '' + #!ipxe + kernel ${pkgs.stdenv.hostPlatform.platform.kernelTarget} init=${config.system.build.toplevel}/init initrd=initrd ${toString config.boot.kernelParams} + ${builtins.concatStringsSep "\n" (builtins.attrValues (builtins.mapAttrs (name: path: "initrd ${name}") initrds))} + initrd initrd + boot + ''; +} '' + mkdir stage + cd stage + ln -s "${config.system.build.kernel}/${pkgs.stdenv.hostPlatform.platform.kernelTarget}" ./ + + set -x + ${builtins.concatStringsSep "\n" + ( + builtins.attrValues + ( + builtins.mapAttrs + ( + name: path: '' + test -f "$(realpath "${path}")" + ln -s ${path} ./${name} + '' + ) initrds + ) + )} + set +x + echo "$pxe" > netboot.ipxe + + cd .. + mv stage $out +''