From ab43589fe63b9713f6375c2c1cfe22e1bf23b69f Mon Sep 17 00:00:00 2001 From: Yaroslav Bolyukin Date: Sat, 27 Apr 2024 01:54:09 +0200 Subject: [PATCH] chore: fix go-jsonnet benchmarking --- nix/benchmarks.nix | 24 ++++++++++++++++++------ nix/go-jsonnet.nix | 13 ++++++++----- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/nix/benchmarks.nix b/nix/benchmarks.nix index bf7199fc..d10160a6 100644 --- a/nix/benchmarks.nix +++ b/nix/benchmarks.nix @@ -67,9 +67,10 @@ stdenv.mkDerivation { unpackPhase = "true"; buildInputs = [ - go-jsonnet sjsonnet jsonnet + rsjsonnet + go-jsonnet hyperfine ]; @@ -79,6 +80,9 @@ stdenv.mkDerivation { mkBench = { name, path, omitSource ? false, pathIsGenerator ? false, skipScala ? "", skipCpp ? "", skipGo ? "", vendor ? "" }: '' set -oux + temp=$(mktemp -d) + cd $temp + echo >> $out echo "### ${name}" >> $out echo >> $out @@ -113,12 +117,12 @@ stdenv.mkDerivation { ''} hyperfine -N -w4 -m20 --output=pipe --style=basic --export-markdown result.md \ ${concatStringsSep " " (forEach jrsonnetVariants (variant: - "\"${variant.drv}/bin/jrsonnet $path ${optionalString (vendor != "") "-J${vendor}"}\" -n \"Rust${if variant.name != "" then " (${variant.name})" else ""}\"" + "\"${variant.drv}/bin/jrsonnet $path${optionalString (vendor != "") " -J${vendor}"}\" -n \"Rust${if variant.name != "" then " (${variant.name})" else ""}\"" ))} \ - "rsjsonnet $path ${optionalString (vendor != "") "-J ${vendor}"}" -n "Rust (alternative, rsjsonnet)" - ${optionalString (skipGo == "") "\"go-jsonnet $path ${optionalString (vendor != "") "-J ${vendor}"}\" -n \"Go\""} \ - ${optionalString (skipScala == "") "\"sjsonnet $path ${optionalString (vendor != "") "-J ${vendor}"}\" -n \"Scala\""} \ - ${optionalString (skipCpp == "") "\"jsonnet $path ${optionalString (vendor != "") "-J ${vendor}"}\" -n \"C++\""} + "rsjsonnet $path${optionalString (vendor != "") " -J ${vendor}"}" -n "Rust (alternative, rsjsonnet)" \ + ${optionalString (skipGo == "") "\"go-jsonnet $path${optionalString (vendor != "") " -J ${vendor}"}\" -n \"Go\""} \ + ${optionalString (skipScala == "") "\"sjsonnet $path${optionalString (vendor != "") " -J ${vendor}"}\" -n \"Scala\""} \ + ${optionalString (skipCpp == "") "\"jsonnet $path${optionalString (vendor != "") " -J ${vendor}"}\" -n \"C++\""} cat result.md >> $out ''; in @@ -151,6 +155,14 @@ stdenv.mkDerivation { echo >> $out echo "" >> $out echo >> $out + echo Rust (alternative): >> $out + echo >> $out + echo "\`\`\`" >> $out + rsjsonnet --help 2>> $out || true + echo "\`\`\`" >> $out + echo >> $out + echo "" >> $out + echo >> $out echo >> $out ''} diff --git a/nix/go-jsonnet.nix b/nix/go-jsonnet.nix index 29e26418..d35e43bf 100644 --- a/nix/go-jsonnet.nix +++ b/nix/go-jsonnet.nix @@ -1,6 +1,9 @@ -{ lib, buildGo119Module, fetchFromGitHub, makeWrapper }: - -buildGo119Module rec { +{ + buildGoModule, + fetchFromGitHub, + makeWrapper, +}: +buildGoModule rec { pname = "go-jsonnet"; version = "0.20.0"; @@ -12,7 +15,7 @@ buildGo119Module rec { }; vendorHash = "sha256-j1fTOUpLx34TgzW94A/BctLrg9XoTtb3cBizhVJoEEI="; - buildInputs = [ makeWrapper ]; + buildInputs = [makeWrapper]; postInstall = '' mv $out/bin/jsonnet $out/bin/go-jsonnet @@ -21,5 +24,5 @@ buildGo119Module rec { doCheck = false; - subPackages = [ "cmd/jsonnet" ]; + subPackages = ["cmd/jsonnet"]; }