1{
2 lib,
3 buildGoModule,
4 fetchFromGitHub,
5 xz,
6 ipxe,
7 stdenv,
8 perl,
9 go-bindata,
10 fetchpatch,
11}:
12
13let
14 rebuildIpxe = stdenv.system == "x86_64-linux";
15in
16buildGoModule rec {
17 pname = "pixiecore";
18 version = "0-unstable-2024-05-31";
19 rev = "2ed7bd30206a51bae786b02d9a5b8156fdcc8870";
20
21 src = fetchFromGitHub {
22 owner = "danderson";
23 repo = "netboot";
24 inherit rev;
25 hash = "sha256-pG4nzzJRWI1rAHS5kBcefNi0ee0/a3jwE+RmR4Dj8jo=";
26 };
27
28 vendorHash = "sha256-3cVGDAZWhmZ1byvjoRodSWMNHCpNujDOAVQKHNntHR8=";
29
30 patches = [
31 # part of https://github.com/danderson/netboot/pull/144
32 # Also backed up in https://github.com/danderson/netboot/compare/main...Mic92:netboot:upgrade-go-mod-117?expand=1
33 (fetchpatch {
34 url = "https://github.com/danderson/netboot/commit/c999a6ca573c973e760c8df531b4c970c21f3d05.patch";
35 sha256 = "sha256-pRWcBz24cqqajLvJffugB/T6lKGVtvOG4ch3vyzDDQQ=";
36 })
37 ];
38
39 doCheck = false;
40
41 # De-vendor ipxe, only on x86_64-linux for now.
42 # In future we can do this also for more systems, if we do cross-compilation.
43 buildInputs = lib.optionals rebuildIpxe [ xz ];
44 nativeBuildInputs = lib.optionals rebuildIpxe [
45 perl
46 go-bindata
47 ];
48 env.NIX_CFLAGS_COMPILE = toString [ "-Wno-error" ];
49 preBuild = lib.optionalString rebuildIpxe ''
50 # don't run in our go-modules phase but only in the normal build phase
51 if echo $NIX_CFLAGS_COMPILE | grep -q xz; then
52 rm -rf ./third_party/ipxe
53 cp -r ${ipxe.src} ./third_party/ipxe
54 chmod -R u+w ./third_party/ipxe
55 make update-ipxe -j$NIX_BUILD_CORES
56 fi
57 '';
58
59 subPackages = [ "cmd/pixiecore" ];
60
61 meta = {
62 description = "Tool to manage network booting of machines";
63 homepage = "https://github.com/danderson/netboot/tree/master/pixiecore";
64 license = lib.licenses.asl20;
65 maintainers = with lib.maintainers; [
66 bbigras
67 mic92
68 ];
69 mainProgram = "pixiecore";
70 };
71}