pxescript: add helper

This commit is contained in:
Graham Christensen 2020-06-07 22:00:01 -04:00
parent b9fe945baf
commit 4bd4603382
No known key found for this signature in database
GPG Key ID: FE918C3A98C1030F
2 changed files with 41 additions and 0 deletions

View File

@ -8,6 +8,8 @@
nix = nixUnstable; nix = nixUnstable;
}; };
makePxeScript = callPackage ./pxescript {};
makeSquashfsManifest = callPackage ./squashfs-recursive { makeSquashfsManifest = callPackage ./squashfs-recursive {
# nixUnstable may not be required. Todo: revisit (2020-05-25) # nixUnstable may not be required. Todo: revisit (2020-05-25)
nix = nixUnstable; nix = nixUnstable;

View File

@ -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
''