{ lib, buildGoModule, buildNpmPackage, fetchFromGitHub, }: let version = "1.9.1"; src = fetchFromGitHub { owner = "skyhook-io"; repo = "radar"; rev = "v${version}"; hash = "sha256-VZLzmxW86yMtYILhmKswkj57KD4Z+8ILwHKiO53YMWE="; }; # Build the frontend as a separate derivation. # The lockfile has some workspace packages without resolved URLs, # so we patch them in postPatch before fetching dependencies. frontend = buildNpmPackage { pname = "radar-frontend"; inherit version src; sourceRoot = "source"; # Upstream lockfile ships complete resolved/integrity fields for all # packages since v1.9.x, so no lockfile patching is needed anymore. npmDepsHash = "sha256-9xS5ChQ1xBix/n9N8vyBsHlHYmYXsibTK5J+X6mRgM4="; npmDepsFetcherVersion = 2; makeCacheWritable = true; doCheck = false; # Build the web workspace and install its output buildPhase = '' runHook preBuild cd web HOME=$TMPDIR ../node_modules/.bin/vite build cd .. runHook postBuild ''; installPhase = '' runHook preInstall mkdir -p $out cp -r web/dist/* $out/ runHook postInstall ''; }; in buildGoModule { pname = "radar"; inherit version src; vendorHash = "sha256-d26tlh+Twv9GFX6NmR25Q9OpP/pUL2T4grdncQHYSg4="; # Copy pre-built frontend assets before Go compilation for go:embed preBuild = '' mkdir -p internal/static/dist cp -r ${frontend}/* internal/static/dist/ ''; env.CGO_ENABLED = 0; ldflags = [ "-s" "-w" "-X main.version=v${version}" ]; subPackages = [ "cmd/explorer" ]; doCheck = false; postInstall = '' ln -s $out/bin/explorer $out/bin/radar ''; passthru = { category = "Kubernetes"; inherit frontend; updateScript = [ "nix-update" "--flake" ".#radar" ]; }; meta = with lib; { description = "Modern Kubernetes visibility — topology, event timeline, service traffic, resource browsing, Helm management, and GitOps support"; homepage = "https://github.com/skyhook-io/radar"; changelog = "https://github.com/skyhook-io/radar/releases/tag/v${version}"; license = licenses.asl20; mainProgram = "radar"; platforms = platforms.linux; }; }