From 307b1c721838cac90b32097708c27f9872237ccc Mon Sep 17 00:00:00 2001 From: Puck Meerburg Date: Sun, 2 Mar 2025 22:13:05 +0000 Subject: [PATCH] (ziclh lang rust): use compile-time path for yj This will have to be replaced with a small Rust program, but I don't want to resolve the chicken-egg problem right now. --- lang/rust/default.nix | 4 +++- lang/rust/src/cargo.sld | 3 ++- lang/rust/src/registry.sld | 4 +++- shell.nix | 1 - 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lang/rust/default.nix b/lang/rust/default.nix index be0f958..ca143eb 100644 --- a/lang/rust/default.nix +++ b/lang/rust/default.nix @@ -1,4 +1,4 @@ -{ chickenPackages, libsodium, callPackage, xxd }: +{ chickenPackages, libsodium, callPackage, xxd, yj }: (callPackage ../../lib/build-chicken-parallel {}) { name = "zilch-lang-rust"; src = ./.; @@ -14,6 +14,8 @@ xxd ]; + + overrides.NIX_CFLAGS_COMPILE = "-DYJ_PATH=\"${yj}/bin/yj\""; overrides.preBuild = '' (cat ${./helpers/src/bin/buildscript-runner.rs}; printf '\0') | xxd -i -n runner_source > runner_source.h (cat ${./helpers/src/bin/rustc-wrapper.rs}; printf '\0') | xxd -i -n rustc_wrap_source > rustc_wrap_source.h diff --git a/lang/rust/src/cargo.sld b/lang/rust/src/cargo.sld index 1ca1611..5f04999 100644 --- a/lang/rust/src/cargo.sld +++ b/lang/rust/src/cargo.sld @@ -44,10 +44,11 @@ (begin (define linker (delay (let ((v (cdr (assoc "out" (nixpkgs "gcc"))))) #~,(string-append #$v "/bin/cc")))) + (define yj-path (foreign-value "YJ_PATH" nonnull-c-string)) ;; Shell out to a TOML-to-JSON parser. This will be replaced with a Nix-native solution later(tm). (define (parse-toml toml-to-parse) - (define-values (read-port write-port pid) (process "yj" '("yj" "-tj"))) + (define-values (read-port write-port pid) (process yj-path '("yj" "-tj"))) (write-string toml-to-parse write-port) (close-output-port write-port) (define parsed (json-read read-port)) diff --git a/lang/rust/src/registry.sld b/lang/rust/src/registry.sld index 0344c8c..6bdde12 100644 --- a/lang/rust/src/registry.sld +++ b/lang/rust/src/registry.sld @@ -15,9 +15,11 @@ lockfile-entry? lockfile-entry-name lockfile-entry-version lockfile-entry-source lockfile-entry-checksum lockfile-entry-dependencies) (begin + (define yj-path (foreign-value "YJ_PATH" nonnull-c-string)) + ;; Shell out to a TOML-to-JSON parser. This will be replaced with a Nix-native solution later(tm). (define (parse-toml toml-to-parse) - (define-values (read-port write-port pid) (process "yj" '("yj" "-tj"))) + (define-values (read-port write-port pid) (process yj-path '("yj" "-tj"))) (write-string toml-to-parse write-port) (close-output-port write-port) (define parsed (json-read read-port)) diff --git a/shell.nix b/shell.nix index 86261b2..df87abf 100644 --- a/shell.nix +++ b/shell.nix @@ -27,7 +27,6 @@ pkgs.mkShell { pkgs.nodejs pkgs.bpftrace pkgs.s6 - pkgs.yj pkgs.rlwrap ];