From 27591c127a0c052f781049154999b756716e7e42 Mon Sep 17 00:00:00 2001 From: Luna Simons Date: Thu, 8 Jan 2026 15:52:48 +0100 Subject: [PATCH] fleet: package with frontend Previously, when running the Fleet server, any requests that fetch templates or assets will fail as they are not included in this package. With this addition, the required files will be built using webpack and included in the go build using go-bindata (as per upstream). --- pkgs/by-name/fl/fleet/package.nix | 65 +++++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 4 deletions(-) diff --git a/pkgs/by-name/fl/fleet/package.nix b/pkgs/by-name/fl/fleet/package.nix index 1224bb1f33d9..1b3feb13c58c 100644 --- a/pkgs/by-name/fl/fleet/package.nix +++ b/pkgs/by-name/fl/fleet/package.nix @@ -1,20 +1,59 @@ { lib, fetchFromGitHub, + stdenvNoCC, + yarnConfigHook, + yarnBuildHook, + nodejs_24, + fetchYarnDeps, buildGoModule, + go-bindata, versionCheckHook, }: - -buildGoModule (finalAttrs: { +let pname = "fleet"; version = "4.78.1"; - src = fetchFromGitHub { owner = "fleetdm"; repo = "fleet"; - tag = "fleet-v${finalAttrs.version}"; + tag = "fleet-v${version}"; hash = "sha256-3F9vzY1JAw2DMzUhMl7j9I8RGjVXulQH2JcYCFuAwDY="; }; + + frontend = stdenvNoCC.mkDerivation { + pname = "${pname}-frontend"; + inherit version src; + + nativeBuildInputs = [ + yarnConfigHook + yarnBuildHook + nodejs_24 + ]; + + yarnOfflineCache = fetchYarnDeps { + yarnLock = src + "/yarn.lock"; + hash = "sha256-cCf0Q6g+VJaTCOZ12/7z8gcDf3+YT2LBTCJb39InJVw="; + }; + + NODE_ENV = "production"; + yarnBuildScript = "webpack"; + + installPhase = '' + runHook preInstall + + mkdir -p $out/assets + cp -r assets/* $out/assets/ + + mkdir -p $out/frontend/templates + cp frontend/templates/react.tmpl $out/frontend/templates/react.tmpl + + runHook postInstall + ''; + }; +in +buildGoModule (finalAttrs: { + inherit pname version src; + vendorHash = "sha256-EwPbZLcqJV5J7ieoQwAJLIn4wwMlwZoTtWaXgvY3pR0="; subPackages = [ @@ -26,12 +65,29 @@ buildGoModule (finalAttrs: { "-X github.com/fleetdm/fleet/v4/server/version.version=${finalAttrs.version}" ]; + nativeBuildInputs = [ go-bindata ]; + + preBuild = '' + cp -r ${frontend}/assets/* assets + cp -r ${frontend}/frontend/templates/react.tmpl frontend/templates/react.tmpl + + go-bindata -pkg=bindata -tags full \ + -o=server/bindata/generated.go \ + frontend/templates/ assets/... server/mail/templates + ''; + + tags = [ "full" ]; + doInstallCheck = true; versionCheckProgramArg = "version"; nativeInstallCheckInputs = [ versionCheckHook ]; + passthru = { + inherit frontend; + }; + meta = { homepage = "https://github.com/fleetdm/fleet"; changelog = "https://github.com/fleetdm/fleet/releases/tag/fleet-v${finalAttrs.version}"; @@ -40,6 +96,7 @@ buildGoModule (finalAttrs: { maintainers = with lib.maintainers; [ asauzeau lesuisse + bddvlpr ]; mainProgram = "fleet"; };