(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.
This commit is contained in:
puck 2025-03-02 22:13:05 +00:00
parent cb046ea859
commit 307b1c7218
4 changed files with 8 additions and 4 deletions

View file

@ -1,4 +1,4 @@
{ chickenPackages, libsodium, callPackage, xxd }: { chickenPackages, libsodium, callPackage, xxd, yj }:
(callPackage ../../lib/build-chicken-parallel {}) { (callPackage ../../lib/build-chicken-parallel {}) {
name = "zilch-lang-rust"; name = "zilch-lang-rust";
src = ./.; src = ./.;
@ -14,6 +14,8 @@
xxd xxd
]; ];
overrides.NIX_CFLAGS_COMPILE = "-DYJ_PATH=\"${yj}/bin/yj\"";
overrides.preBuild = '' overrides.preBuild = ''
(cat ${./helpers/src/bin/buildscript-runner.rs}; printf '\0') | xxd -i -n runner_source > runner_source.h (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 (cat ${./helpers/src/bin/rustc-wrapper.rs}; printf '\0') | xxd -i -n rustc_wrap_source > rustc_wrap_source.h

View file

@ -44,10 +44,11 @@
(begin (begin
(define linker (delay (let ((v (cdr (assoc "out" (nixpkgs "gcc"))))) #~,(string-append #$v "/bin/cc")))) (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). ;; 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 (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) (write-string toml-to-parse write-port)
(close-output-port write-port) (close-output-port write-port)
(define parsed (json-read read-port)) (define parsed (json-read read-port))

View file

@ -15,9 +15,11 @@
lockfile-entry? lockfile-entry-name lockfile-entry-version lockfile-entry-source lockfile-entry-checksum lockfile-entry-dependencies) lockfile-entry? lockfile-entry-name lockfile-entry-version lockfile-entry-source lockfile-entry-checksum lockfile-entry-dependencies)
(begin (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). ;; 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 (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) (write-string toml-to-parse write-port)
(close-output-port write-port) (close-output-port write-port)
(define parsed (json-read read-port)) (define parsed (json-read read-port))

View file

@ -27,7 +27,6 @@ pkgs.mkShell {
pkgs.nodejs pkgs.nodejs
pkgs.bpftrace pkgs.bpftrace
pkgs.s6 pkgs.s6
pkgs.yj
pkgs.rlwrap pkgs.rlwrap
]; ];