Skip to content

Commit

Permalink
feat: another Rust jsonnet implementation appears!
Browse files Browse the repository at this point in the history
  • Loading branch information
CertainLach committed Apr 26, 2024
1 parent 9fc25c5 commit e720fc5
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ There already are multiple implementations of this standard implemented in diffe
* https://github.com/google/jsonnet[C++];
* https://github.com/google/go-jsonnet/[Go];
* https://github.com/databricks/sjsonnet[Scala].
* [NEW] https://github.com/eduardosm/rsjsonnet[Another Rust impl appears].

This implementation shows performance better than all existing implementations.
For more information see link:./docs/benchmarks.md[benchmarks]
Expand Down
9 changes: 5 additions & 4 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
jsonnet = pkgs.callPackage ./nix/jsonnet.nix {};
# I didn't managed to build it, and nixpkgs version is marked as broken
# haskell-jsonnet = pkgs.callPackage ./nix/haskell-jsonnet.nix { };
rsjsonnet = pkgs.callPackage ./nix/rsjsonnet.nix {};

jrsonnet = pkgs.callPackage ./nix/jrsonnet.nix {
inherit craneLib;
Expand All @@ -60,7 +61,7 @@
};

benchmarks = pkgs.callPackage ./nix/benchmarks.nix {
inherit go-jsonnet sjsonnet jsonnet;
inherit go-jsonnet sjsonnet jsonnet rsjsonnet;
jrsonnetVariants = [
{
drv = jrsonnet.override {forBenchmarks = true;};
Expand All @@ -69,7 +70,7 @@
];
};
benchmarks-quick = pkgs.callPackage ./nix/benchmarks.nix {
inherit go-jsonnet sjsonnet jsonnet;
inherit go-jsonnet sjsonnet jsonnet rsjsonnet;
quick = true;
jrsonnetVariants = [
{
Expand All @@ -79,7 +80,7 @@
];
};
benchmarks-against-release = pkgs.callPackage ./nix/benchmarks.nix {
inherit go-jsonnet sjsonnet jsonnet;
inherit go-jsonnet sjsonnet jsonnet rsjsonnet;
jrsonnetVariants = [
{
drv = jrsonnet.override {forBenchmarks = true;};
Expand All @@ -96,7 +97,7 @@
];
};
benchmarks-quick-against-release = pkgs.callPackage ./nix/benchmarks.nix {
inherit go-jsonnet sjsonnet jsonnet;
inherit go-jsonnet sjsonnet jsonnet rsjsonnet;
quick = true;
jrsonnetVariants = [
{
Expand Down
2 changes: 2 additions & 0 deletions nix/benchmarks.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
, go-jsonnet
, sjsonnet
, jsonnet
, rsjsonnet
, hyperfine
, quick ? false
, jrsonnetVariants
Expand Down Expand Up @@ -114,6 +115,7 @@ stdenv.mkDerivation {
${concatStringsSep " " (forEach jrsonnetVariants (variant:
"\"${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++\""}
Expand Down
18 changes: 18 additions & 0 deletions nix/rsjsonnet.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
fetchFromGitHub,
rustPlatform,
lib,
}:
rustPlatform.buildRustPackage rec {
pname = "rsjsonnet";
version = "0.1.1";

src = fetchFromGitHub {
owner = "eduardosm";
repo = pname;
rev = "v${version}";
hash = "sha256-C6hZYGllKrKKMwMwss6PK2UD5Zb7bk2v8DrGpWnwP/A=";
};

cargoHash = "sha256-TsUN9oUu6S1l9oTaR6nET1ZdRvMrR29bkP3VEDre8aE=";
}

0 comments on commit e720fc5

Please sign in to comment.