From 4bd4603382e0e29a61e225d6d78d3989143d6451 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Sun, 7 Jun 2020 22:00:01 -0400 Subject: [PATCH] pxescript: add helper --- pkgs/default.nix | 2 ++ pkgs/pxescript/default.nix | 39 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 pkgs/pxescript/default.nix 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 +''