diff --git a/cabal.project b/cabal.project index b98686e..906a8ed 100644 --- a/cabal.project +++ b/cabal.project @@ -15,7 +15,7 @@ source-repository-package type: git location: https://github.com/well-typed/hs-bindgen tag: e2a9260678d9fa76dab602a5a07927acada3be4f - subdir: c-expr-dsl c-expr-runtime hs-bindgen hs-bindgen-runtime + subdir: c-expr-dsl c-expr-runtime hs-bindgen-runtime --sha256: 0nrs3iq0l5ha5kxyhqnlmvgi7734pmzyp3zf7p8s1gb21ylh4sy0 source-repository-package type: git diff --git a/flake.lock b/flake.lock index b2297eb..7652984 100644 --- a/flake.lock +++ b/flake.lock @@ -115,6 +115,24 @@ "type": "github" } }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1769996383, + "narHash": "sha256-AnYjnFWgS49RlqX7LrC4uA+sCCDBj0Ry/WOJ5XWAsa0=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "57928607ea566b5db3ad13af0e57e921e6b12381", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, "flake-utils": { "inputs": { "systems": "systems" @@ -507,6 +525,27 @@ "type": "github" } }, + "hs-bindgen": { + "inputs": { + "flake-parts": "flake-parts", + "libclang-bindings-src": "libclang-bindings-src", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1770394582, + "narHash": "sha256-erbj5xqqJ/M0c99G0vjZvJtvoxYJ1PG7DDkw15MVLK8=", + "owner": "well-typed", + "repo": "hs-bindgen", + "rev": "e2a9260678d9fa76dab602a5a07927acada3be4f", + "type": "github" + }, + "original": { + "owner": "well-typed", + "ref": "release-0.1-alpha", + "repo": "hs-bindgen", + "type": "github" + } + }, "iserv-proxy": { "flake": false, "locked": { @@ -524,6 +563,39 @@ "type": "github" } }, + "libclang-bindings-src": { + "flake": false, + "locked": { + "lastModified": 1770274896, + "narHash": "sha256-JnxJBo2L4URFD8JbpjnPG/ej/xKFe7y5ZpjnvIztwAM=", + "owner": "well-typed", + "repo": "libclang", + "rev": "155642a4a4a9f0414a058a8f08f39aa6c7bb57ed", + "type": "github" + }, + "original": { + "owner": "well-typed", + "repo": "libclang", + "rev": "155642a4a4a9f0414a058a8f08f39aa6c7bb57ed", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1770169770, + "narHash": "sha256-awR8qIwJxJJiOmcEGgP2KUqYmHG4v/z8XpL9z8FnT1A=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "aa290c9891fa4ebe88f8889e59633d20cc06a5f2", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "nixpkgs-2305": { "locked": { "lastModified": 1705033721, @@ -620,6 +692,21 @@ "type": "github" } }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1769909678, + "narHash": "sha256-cBEymOf4/o3FD5AZnzC3J9hLbiZ+QDT/KDuyHXVJOpM=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "72716169fe93074c333e8d0173151350670b824c", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, "nixpkgs-unstable": { "locked": { "lastModified": 1764587062, @@ -659,6 +746,7 @@ "flake-utils": "flake-utils", "haskellNix": "haskellNix", "hls-2-13": "hls-2-13", + "hs-bindgen": "hs-bindgen", "nixpkgs": [ "haskellNix", "nixpkgs-2511" diff --git a/flake.nix b/flake.nix index 07a5889..7e58e7a 100644 --- a/flake.nix +++ b/flake.nix @@ -9,6 +9,7 @@ url = "github:oxalica/rust-overlay"; inputs.nixpkgs.follows = "nixpkgs"; }; + hs-bindgen.url = "github:well-typed/hs-bindgen/release-0.1-alpha"; }; outputs = { self @@ -18,6 +19,7 @@ , hls-2-13 , crane , rust-overlay + , hs-bindgen }: flake-utils.lib.eachSystem [ "x86_64-linux" ] (system: let @@ -60,7 +62,9 @@ packages = with pkgs; [ bacon ghcid + hs-bindgen.packages.${system}.hs-bindgen-cli rust-analyzer + rust-cbindgen ]; }; } diff --git a/generate-bindings b/generate-bindings index 30d4b1b..7c9c9fc 100755 --- a/generate-bindings +++ b/generate-bindings @@ -7,8 +7,7 @@ set -euo pipefail # # Pipeline: cargo build -> cbindgen -> patch header -> hs-bindgen # -# Prerequisites: run inside the Nix dev shell (provides gcc, cabal, etc.) -# cbindgen is fetched via `nix run nixpkgs#rust-cbindgen`. +# Prerequisites: run inside the Nix dev shell (provides gcc, cabal, cbindgen, hs-bindgen-cli). SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" RUST_DIR="$SCRIPT_DIR/rust" @@ -22,7 +21,7 @@ cargo build --manifest-path "$RUST_DIR/Cargo.toml" # --- Step 2: Generate C header with cbindgen --- echo "=== Running cbindgen ===" -nix run nixpkgs#rust-cbindgen -- \ +cbindgen \ --lang c \ --crate garnet-rs \ --output "$HEADER" \ @@ -116,7 +115,7 @@ fi # --- Step 5: Run hs-bindgen --- echo "=== Running hs-bindgen ===" -cabal run -- hs-bindgen-cli preprocess \ +hs-bindgen-cli preprocess \ --overwrite-files --create-output-dirs \ --unique-id com.garnet --enable-record-dot \ --hs-output-dir "$HASKELL_DIR/generated" --module GarnetRs \