From 21963ee1bc53c74a64af40e0dfb6541c2d0a9d34 Mon Sep 17 00:00:00 2001 From: Austin Horstman Date: Sat, 6 Jun 2026 10:21:21 -0500 Subject: [PATCH] kulala-fmt: 1.4.0 -> 3.1.0 Changelog: https://github.com/mistweaverco/kulala-fmt/compare/v1.4.0...v3.1.0 --- pkgs/by-name/ku/kulala-fmt/package.nix | 104 ++++++++++++++++++++++--- 1 file changed, 92 insertions(+), 12 deletions(-) diff --git a/pkgs/by-name/ku/kulala-fmt/package.nix b/pkgs/by-name/ku/kulala-fmt/package.nix index 08c80cb86ef2..b1b29d22a2df 100644 --- a/pkgs/by-name/ku/kulala-fmt/package.nix +++ b/pkgs/by-name/ku/kulala-fmt/package.nix @@ -1,36 +1,116 @@ { lib, - buildGoModule, + stdenv, + bun, fetchFromGitHub, + kulala-core, + makeBinaryWrapper, + nodejs, + writableTmpDirAsHomeHook, }: -buildGoModule (finalAttrs: { +stdenv.mkDerivation (finalAttrs: { pname = "kulala-fmt"; - version = "1.4.0"; + version = "3.1.0"; + + strictDeps = true; + __structuredAttrs = true; src = fetchFromGitHub { owner = "mistweaverco"; repo = "kulala-fmt"; - rev = "v${finalAttrs.version}"; - hash = "sha256-yq7DMrt+g5wM/tynI7Cf6MBJs/d+fP3IppndKnTJMTw="; + tag = "v${finalAttrs.version}"; + hash = "sha256-4rVsw3dyoKrC6lj8m2R42iZmBk5G2LIVtV6Ro9pHSBo="; }; - vendorHash = "sha256-GazDEm/qv0nh8vYT+Tf0n4QDGHlcYtbMIj5rlZBvpKo="; + node_modules = stdenv.mkDerivation { + pname = "${finalAttrs.pname}-node_modules"; + inherit (finalAttrs) version src; - env.CGO_ENABLED = 0; + strictDeps = true; + __structuredAttrs = true; - ldflags = [ - "-s" - "-w" - "-X github.com/mistweaverco/kulala-fmt/cmd/kulalafmt.VERSION=${finalAttrs.version}" + nativeBuildInputs = [ + bun + writableTmpDirAsHomeHook + ]; + + dontConfigure = true; + + buildPhase = '' + runHook preBuild + + bun install \ + --cpu="*" \ + --frozen-lockfile \ + --ignore-scripts \ + --no-progress \ + --os="*" + + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + + mkdir -p $out + cp -R node_modules $out/ + + runHook postInstall + ''; + + dontFixup = true; + + outputHash = "sha256-z+jQC2RCav3VG/agWizcWFat8KgkGdBzaGQriviEbyo="; + outputHashAlgo = "sha256"; + outputHashMode = "recursive"; + }; + + nativeBuildInputs = [ + bun + makeBinaryWrapper + nodejs ]; + dontConfigure = true; + + buildPhase = '' + runHook preBuild + + cp -R ${finalAttrs.node_modules}/node_modules . + patchShebangs node_modules + bun run build + + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + + install -Dm755 dist/cli.cjs $out/lib/kulala-fmt/cli.cjs + makeBinaryWrapper ${lib.getExe nodejs} $out/bin/kulala-fmt \ + --add-flags $out/lib/kulala-fmt/cli.cjs \ + --set KULALA_CORE_PATH ${lib.getExe kulala-core} + + runHook postInstall + ''; + + doInstallCheck = true; + installCheckPhase = '' + runHook preInstallCheck + + $out/bin/kulala-fmt --version | grep -x ${lib.escapeShellArg finalAttrs.version} + printf '%s\n' 'GET https://example.com' | $out/bin/kulala-fmt format --stdin | grep 'GET https://example.com' + + runHook postInstallCheck + ''; + meta = { description = "Opinionated .http and .rest files linter and formatter"; homepage = "https://github.com/mistweaverco/kulala-fmt"; license = lib.licenses.mit; maintainers = with lib.maintainers; [ CnTeng ]; mainProgram = "kulala-fmt"; - platforms = lib.platforms.all; + platforms = nodejs.meta.platforms; }; })