From 1cbf286f186fe72c8d93f0b8efea63b5fca3ac0a Mon Sep 17 00:00:00 2001 From: Yureka Date: Thu, 1 Aug 2024 22:47:25 +0200 Subject: [PATCH] build netboot files from hydra --- flake.nix | 2 +- services/baremetal-builder/default.nix | 35 +++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 0174d9d..ce9ca5c 100644 --- a/flake.nix +++ b/flake.nix @@ -114,7 +114,7 @@ public01.imports = commonModules ++ [ ./hosts/public01 ]; } // builders; - hydraJobs = builtins.mapAttrs (n: v: v.config.system.build.toplevel) self.nixosConfigurations; + hydraJobs = builtins.mapAttrs (n: v: v.config.system.build.netbootDir or v.config.system.build.toplevel) self.nixosConfigurations; buildbotJobs = builtins.mapAttrs (_: v: v.config.system.build.toplevel) self.nixosConfigurations; }; } diff --git a/services/baremetal-builder/default.nix b/services/baremetal-builder/default.nix index 9c5e58d..5157b18 100644 --- a/services/baremetal-builder/default.nix +++ b/services/baremetal-builder/default.nix @@ -1,4 +1,4 @@ -{ pkgs, lib, config, ... }: +{ pkgs, lib, config, extendModules, ... }: let cfg = config.bagel.baremetal.builders; in @@ -177,6 +177,39 @@ in environment.systemPackages = [ pkgs.ipmitool ]; + system.build = lib.mkIf cfg.netboot { + netbootVariant = extendModules { + modules = [ + ( + { modulesPath, ... }: + + { + imports = [ (modulesPath + "/installer/netboot/netboot.nix") ]; + } + ) + ]; + }; + netbootDir = let + kernelTarget = pkgs.stdenv.hostPlatform.linux-kernel.target; + build = config.system.build.netbootVariant.config.system.build; + in + pkgs.symlinkJoin { + name = "netboot"; + paths = [ + build.netbootRamdisk + build.kernel + build.netbootIpxeScript + ]; + postBuild = '' + mkdir -p $out/nix-support + echo "file ${kernelTarget} ${build.kernel}/${kernelTarget}" >> $out/nix-support/hydra-build-products + echo "file initrd ${build.netbootRamdisk}/initrd" >> $out/nix-support/hydra-build-products + echo "file ipxe ${build.netbootIpxeScript}/netboot.ipxe" >> $out/nix-support/hydra-build-products + ''; + preferLocalBuild = true; + }; + }; + system.stateVersion = "24.05"; }; }