From f3b4f74b806a3a432aa5d6390ff36bbe31674255 Mon Sep 17 00:00:00 2001 From: benjmhart Date: Wed, 2 Sep 2026 16:22:39 -0400 Subject: [PATCH] rust: build plutus-ledger-api from a local checkout Removes the crates.io publish round-trip when developing plutus-ledger-api alongside lambda-buffers. - flake.nix: new `plutus-ledger-api-rust` input pointing at a local checkout of mlabs-haskell/plutus-ledger-api-rust. - lbt-plutus-rust/build.nix: add its `plutus-ledger-api-rust-src` and `is-plutus-data-derive-rust-src` to `extraSources`, so they land under `.extras/plutus-ledger-api-3` and `.extras/is-plutus-data-derive-0`. - lbt-plutus-rust/Cargo.toml: `[patch.crates-io]` redirects plutus-ledger-api to `.extras/plutus-ledger-api-3`. Applied at the workspace root, so the generated lbf-* crates under `.extras` are redirected too and `extras/lbf-nix/lbf-rust.nix`'s versionTable needs no change. - Cargo.lock: plutus-ledger-api and is-plutus-data-derive lose their `source`/`checksum` and become path entries. lbt-plutus is the only crate in the repo depending on plutus-ledger-api. Verified with `nix build .#lbt-plutus-rust` (compiles plutus-ledger-api from .extras) and `nix build .#checks.x86_64-linux.lbt-plutus-rust-test` (131 passed, 0 failed). NOTE: the input URL is an absolute developer-local path, so CI cannot build this branch as-is. The CI-safe form is `url = "github:mlabs-haskell/plutus-ledger-api-rust"` combined with `--override-input plutus-ledger-api-rust path:$PWD/../plutus-ledger-api-rust`. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01WgwCVCPP5z7vPAcfQGA86a --- flake.lock | 185 +++++++++++++----- flake.nix | 9 + .../lbt-plutus/lbt-plutus-rust/Cargo.lock | 4 - .../lbt-plutus/lbt-plutus-rust/Cargo.toml | 6 + .../lbt-plutus/lbt-plutus-rust/build.nix | 5 + 5 files changed, 157 insertions(+), 52 deletions(-) diff --git a/flake.lock b/flake.lock index d15dd6b5..16e0f344 100644 --- a/flake.lock +++ b/flake.lock @@ -823,6 +823,27 @@ } }, "flake-parts_10": { + "inputs": { + "nixpkgs-lib": [ + "plutus-ledger-api-typescript", + "hci-effects", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1751413152, + "narHash": "sha256-Tyw1RjYEsp5scoigs1384gIg6e0GoBVjms4aXFfRssQ=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "77826244401ea9de6e3bac47c2db46005e1f30b5", + "type": "github" + }, + "original": { + "id": "flake-parts", + "type": "indirect" + } + }, + "flake-parts_11": { "inputs": { "nixpkgs-lib": "nixpkgs-lib_6" }, @@ -840,7 +861,7 @@ "type": "github" } }, - "flake-parts_11": { + "flake-parts_12": { "inputs": { "nixpkgs-lib": [ "plutus-ledger-api-typescript", @@ -862,7 +883,7 @@ "type": "indirect" } }, - "flake-parts_12": { + "flake-parts_13": { "inputs": { "nixpkgs-lib": "nixpkgs-lib_7" }, @@ -880,7 +901,7 @@ "type": "github" } }, - "flake-parts_13": { + "flake-parts_14": { "inputs": { "nixpkgs-lib": [ "proto-nix", @@ -1019,41 +1040,41 @@ }, "flake-parts_8": { "inputs": { - "nixpkgs-lib": "nixpkgs-lib_5" + "nixpkgs-lib": [ + "plutus-ledger-api-rust", + "hci-effects", + "nixpkgs" + ] }, "locked": { - "lastModified": 1754487366, - "narHash": "sha256-pHYj8gUBapuUzKV/kN/tR3Zvqc7o6gdFB9XKXIp1SQ8=", + "lastModified": 1772408722, + "narHash": "sha256-rHuJtdcOjK7rAHpHphUb1iCvgkU3GpfvicLMwwnfMT0=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "af66ad14b28a127c5c0f3bbb298218fc63528a18", + "rev": "f20dc5d9b8027381c474144ecabc9034d6a839a3", "type": "github" }, "original": { - "owner": "hercules-ci", - "repo": "flake-parts", - "type": "github" + "id": "flake-parts", + "type": "indirect" } }, "flake-parts_9": { "inputs": { - "nixpkgs-lib": [ - "plutus-ledger-api-typescript", - "hci-effects", - "nixpkgs" - ] + "nixpkgs-lib": "nixpkgs-lib_5" }, "locked": { - "lastModified": 1751413152, - "narHash": "sha256-Tyw1RjYEsp5scoigs1384gIg6e0GoBVjms4aXFfRssQ=", + "lastModified": 1754487366, + "narHash": "sha256-pHYj8gUBapuUzKV/kN/tR3Zvqc7o6gdFB9XKXIp1SQ8=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "77826244401ea9de6e3bac47c2db46005e1f30b5", + "rev": "af66ad14b28a127c5c0f3bbb298218fc63528a18", "type": "github" }, "original": { - "id": "flake-parts", - "type": "indirect" + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" } }, "flake-utils": { @@ -1702,9 +1723,28 @@ }, "hci-effects_3": { "inputs": { - "flake-parts": "flake-parts_9", + "flake-parts": "flake-parts_8", "nixpkgs": "nixpkgs_17" }, + "locked": { + "lastModified": 1773550609, + "narHash": "sha256-neu7ixXHjV3LobVjOndkL97u+6UF6Yoh+CUnzX7kUBQ=", + "owner": "hercules-ci", + "repo": "hercules-ci-effects", + "rev": "554f6ed448ca74c00aa2371cde901ae1e73005b9", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "hercules-ci-effects", + "type": "github" + } + }, + "hci-effects_4": { + "inputs": { + "flake-parts": "flake-parts_10", + "nixpkgs": "nixpkgs_18" + }, "locked": { "lastModified": 1752595130, "narHash": "sha256-CNBgr4OZSuklGtNOa9CnTNo9+Xceqn/EDAC1Tc43fH8=", @@ -1719,10 +1759,10 @@ "type": "github" } }, - "hci-effects_4": { + "hci-effects_5": { "inputs": { - "flake-parts": "flake-parts_11", - "nixpkgs": "nixpkgs_19" + "flake-parts": "flake-parts_12", + "nixpkgs": "nixpkgs_20" }, "locked": { "lastModified": 1752595130, @@ -1738,10 +1778,10 @@ "type": "github" } }, - "hci-effects_5": { + "hci-effects_6": { "inputs": { - "flake-parts": "flake-parts_13", - "nixpkgs": "nixpkgs_21" + "flake-parts": "flake-parts_14", + "nixpkgs": "nixpkgs_22" }, "locked": { "lastModified": 1752595130, @@ -3615,6 +3655,22 @@ } }, "nixpkgs_17": { + "locked": { + "lastModified": 1773389992, + "narHash": "sha256-wvfdLLWJ2I9oEpDd9PfMA8osfIZicoQ5MT1jIwNs9Tk=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "c06b4ae3d6599a672a6210b7021d699c351eebda", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_18": { "locked": { "lastModified": 1751984180, "narHash": "sha256-LwWRsENAZJKUdD3SpLluwDmdXY9F45ZEgCb0X+xgOL0=", @@ -3630,7 +3686,7 @@ "type": "github" } }, - "nixpkgs_18": { + "nixpkgs_19": { "locked": { "lastModified": 1754895929, "narHash": "sha256-cHSg9CMqEx0e06UkWJLRuLlolRCgPE8zwdEp3JwYRGI=", @@ -3646,13 +3702,13 @@ "type": "github" } }, - "nixpkgs_19": { + "nixpkgs_2": { "locked": { - "lastModified": 1751984180, - "narHash": "sha256-LwWRsENAZJKUdD3SpLluwDmdXY9F45ZEgCb0X+xgOL0=", + "lastModified": 1653581809, + "narHash": "sha256-Uvka0V5MTGbeOfWte25+tfRL3moECDh1VwokWSZUdoY=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "9807714d6944a957c2e036f84b0ff8caf9930bc0", + "rev": "83658b28fe638a170a19b8933aa008b30640fbd1", "type": "github" }, "original": { @@ -3662,13 +3718,13 @@ "type": "github" } }, - "nixpkgs_2": { + "nixpkgs_20": { "locked": { - "lastModified": 1653581809, - "narHash": "sha256-Uvka0V5MTGbeOfWte25+tfRL3moECDh1VwokWSZUdoY=", + "lastModified": 1751984180, + "narHash": "sha256-LwWRsENAZJKUdD3SpLluwDmdXY9F45ZEgCb0X+xgOL0=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "83658b28fe638a170a19b8933aa008b30640fbd1", + "rev": "9807714d6944a957c2e036f84b0ff8caf9930bc0", "type": "github" }, "original": { @@ -3678,7 +3734,7 @@ "type": "github" } }, - "nixpkgs_20": { + "nixpkgs_21": { "locked": { "lastModified": 1759070547, "narHash": "sha256-JVZl8NaVRYb0+381nl7LvPE+A774/dRpif01FKLrYFQ=", @@ -3694,7 +3750,7 @@ "type": "github" } }, - "nixpkgs_21": { + "nixpkgs_22": { "locked": { "lastModified": 1751984180, "narHash": "sha256-LwWRsENAZJKUdD3SpLluwDmdXY9F45ZEgCb0X+xgOL0=", @@ -3710,7 +3766,7 @@ "type": "github" } }, - "nixpkgs_22": { + "nixpkgs_23": { "locked": { "lastModified": 1754340878, "narHash": "sha256-lgmUyVQL9tSnvvIvBp7x1euhkkCho7n3TMzgjdvgPoU=", @@ -3962,14 +4018,46 @@ "type": "github" } }, - "plutus-ledger-api-typescript": { + "plutus-ledger-api-rust": { "inputs": { "flake-lang": [ "flake-lang" ], - "flake-parts": "flake-parts_8", + "flake-parts": [ + "plutus-ledger-api-rust", + "flake-lang", + "flake-parts" + ], "hci-effects": "hci-effects_3", - "nixpkgs": "nixpkgs_18", + "nixpkgs": [ + "plutus-ledger-api-rust", + "flake-lang", + "nixpkgs" + ], + "pre-commit-hooks": [ + "plutus-ledger-api-rust", + "flake-lang", + "pre-commit-hooks" + ] + }, + "locked": { + "narHash": "sha256-EjISb9FYeI9b10Ot3XV6liFxHy8WmVEyxU16Ho9aY1M=", + "path": "/home/ben/projects/lambda-buffers/plutus-ledger-api-rust", + "type": "path" + }, + "original": { + "path": "/home/ben/projects/lambda-buffers/plutus-ledger-api-rust", + "type": "path" + } + }, + "plutus-ledger-api-typescript": { + "inputs": { + "flake-lang": [ + "flake-lang" + ], + "flake-parts": "flake-parts_9", + "hci-effects": "hci-effects_4", + "nixpkgs": "nixpkgs_19", "pre-commit-hooks-nix": "pre-commit-hooks-nix", "prelude-typescript": "prelude-typescript" }, @@ -4079,7 +4167,7 @@ "inputs": { "flake-compat": "flake-compat_11", "gitignore": "gitignore_5", - "nixpkgs": "nixpkgs_20" + "nixpkgs": "nixpkgs_21" }, "locked": { "lastModified": 1759523803, @@ -4099,7 +4187,7 @@ "inputs": { "flake-compat": "flake-compat_12", "gitignore": "gitignore_6", - "nixpkgs": "nixpkgs_22" + "nixpkgs": "nixpkgs_23" }, "locked": { "lastModified": 1754416808, @@ -4121,8 +4209,8 @@ "plutus-ledger-api-typescript", "flake-lang" ], - "flake-parts": "flake-parts_10", - "hci-effects": "hci-effects_4", + "flake-parts": "flake-parts_11", + "hci-effects": "hci-effects_5", "nixpkgs": [ "plutus-ledger-api-typescript", "nixpkgs" @@ -4146,8 +4234,8 @@ }, "proto-nix": { "inputs": { - "flake-parts": "flake-parts_12", - "hci-effects": "hci-effects_5", + "flake-parts": "flake-parts_13", + "hci-effects": "hci-effects_6", "http2-grpc-native": "http2-grpc-native", "nixpkgs": [ "nixpkgs" @@ -4196,6 +4284,7 @@ "nixpkgs" ], "plutarch": "plutarch_2", + "plutus-ledger-api-rust": "plutus-ledger-api-rust", "plutus-ledger-api-typescript": "plutus-ledger-api-typescript", "pre-commit-hooks": "pre-commit-hooks_3", "prelude-typescript": [ diff --git a/flake.nix b/flake.nix index 8d326817..9b43b14a 100644 --- a/flake.nix +++ b/flake.nix @@ -36,6 +36,15 @@ # Plutarch eDSL (LB Codegen target) plutarch.url = "github:Plutonomicon/plutarch-plutus"; + # Rust runtime for LB Plutus. Points at a local checkout so `plutus-ledger-api` + # can be developed in-tree without a crates.io release round-trip. `path:` inputs + # copy the working directory, so uncommitted edits there are picked up. + # LOCAL DEV ONLY -- do not push this line; CI wants the github: URL. + plutus-ledger-api-rust = { + url = "path:/home/ben/projects/lambda-buffers/plutus-ledger-api-rust"; + inputs.flake-lang.follows = "flake-lang"; + }; + # Typescript runtimes prelude-typescript.follows = "plutus-ledger-api-typescript/prelude-typescript"; plutus-ledger-api-typescript = { diff --git a/testsuites/lbt-plutus/lbt-plutus-rust/Cargo.lock b/testsuites/lbt-plutus/lbt-plutus-rust/Cargo.lock index 775d6350..825cbbb7 100644 --- a/testsuites/lbt-plutus/lbt-plutus-rust/Cargo.lock +++ b/testsuites/lbt-plutus/lbt-plutus-rust/Cargo.lock @@ -321,8 +321,6 @@ checksum = "90f97a5f38dd3ccfbe7aa80f4a0c00930f21b922c74195be0201c51028f22dcf" [[package]] name = "is-plutus-data-derive" version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8833aaa98fd02a031afb0640e7d6259ac29fd22c646299114793ddea5795639" dependencies = [ "proc-macro2", "quote", @@ -570,8 +568,6 @@ checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" [[package]] name = "plutus-ledger-api" version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b1e082eae586833f73a2a43336b45403c0700b78e3c0881c90fb827b8af8a65" dependencies = [ "anyhow", "cardano-serialization-lib", diff --git a/testsuites/lbt-plutus/lbt-plutus-rust/Cargo.toml b/testsuites/lbt-plutus/lbt-plutus-rust/Cargo.toml index aee9c7eb..ec587d47 100644 --- a/testsuites/lbt-plutus/lbt-plutus-rust/Cargo.toml +++ b/testsuites/lbt-plutus/lbt-plutus-rust/Cargo.toml @@ -13,3 +13,9 @@ lbr-prelude = { version = "0.1.3" } serde_json = "1.0.108" num-bigint = "0.4.4" pretty_assertions = "1.4.1" + +# Resolve `plutus-ledger-api` from the local checkout wired in through +# `extraSources` in build.nix rather than from crates.io. Applies to the whole +# dependency graph, including the generated lbf-* crates under `.extras`. +[patch.crates-io] +plutus-ledger-api = { path = ".extras/plutus-ledger-api-3" } diff --git a/testsuites/lbt-plutus/lbt-plutus-rust/build.nix b/testsuites/lbt-plutus/lbt-plutus-rust/build.nix index 5c94e269..a8f3b1ea 100644 --- a/testsuites/lbt-plutus/lbt-plutus-rust/build.nix +++ b/testsuites/lbt-plutus/lbt-plutus-rust/build.nix @@ -13,6 +13,11 @@ config.packages.lbf-plutus-golden-api-rust config.packages.lbf-prelude-rust config.packages.lbf-plutus-rust + # Local plutus-ledger-api checkout, wired in via `[patch.crates-io]` in + # Cargo.toml so every crate in the graph (including the generated lbf-* + # crates) resolves to it instead of the crates.io release. + inputs.plutus-ledger-api-rust.packages.${system}.plutus-ledger-api-rust-src + inputs.plutus-ledger-api-rust.packages.${system}.is-plutus-data-derive-rust-src ]; data = [ {