Add Bash script dependencies to Nix shell

This commit is contained in:
George Thomas 2026-02-19 12:56:10 +00:00
parent 13b9324bc4
commit f1ec06fcca
4 changed files with 96 additions and 5 deletions

View File

@ -15,7 +15,7 @@ source-repository-package
type: git type: git
location: https://github.com/well-typed/hs-bindgen location: https://github.com/well-typed/hs-bindgen
tag: e2a9260678d9fa76dab602a5a07927acada3be4f 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 --sha256: 0nrs3iq0l5ha5kxyhqnlmvgi7734pmzyp3zf7p8s1gb21ylh4sy0
source-repository-package source-repository-package
type: git type: git

88
flake.lock generated
View File

@ -115,6 +115,24 @@
"type": "github" "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": { "flake-utils": {
"inputs": { "inputs": {
"systems": "systems" "systems": "systems"
@ -507,6 +525,27 @@
"type": "github" "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": { "iserv-proxy": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -524,6 +563,39 @@
"type": "github" "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": { "nixpkgs-2305": {
"locked": { "locked": {
"lastModified": 1705033721, "lastModified": 1705033721,
@ -620,6 +692,21 @@
"type": "github" "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": { "nixpkgs-unstable": {
"locked": { "locked": {
"lastModified": 1764587062, "lastModified": 1764587062,
@ -659,6 +746,7 @@
"flake-utils": "flake-utils", "flake-utils": "flake-utils",
"haskellNix": "haskellNix", "haskellNix": "haskellNix",
"hls-2-13": "hls-2-13", "hls-2-13": "hls-2-13",
"hs-bindgen": "hs-bindgen",
"nixpkgs": [ "nixpkgs": [
"haskellNix", "haskellNix",
"nixpkgs-2511" "nixpkgs-2511"

View File

@ -9,6 +9,7 @@
url = "github:oxalica/rust-overlay"; url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
hs-bindgen.url = "github:well-typed/hs-bindgen/release-0.1-alpha";
}; };
outputs = outputs =
{ self { self
@ -18,6 +19,7 @@
, hls-2-13 , hls-2-13
, crane , crane
, rust-overlay , rust-overlay
, hs-bindgen
}: }:
flake-utils.lib.eachSystem [ "x86_64-linux" ] (system: flake-utils.lib.eachSystem [ "x86_64-linux" ] (system:
let let
@ -60,7 +62,9 @@
packages = with pkgs; [ packages = with pkgs; [
bacon bacon
ghcid ghcid
hs-bindgen.packages.${system}.hs-bindgen-cli
rust-analyzer rust-analyzer
rust-cbindgen
]; ];
}; };
} }

View File

@ -7,8 +7,7 @@ set -euo pipefail
# #
# Pipeline: cargo build -> cbindgen -> patch header -> hs-bindgen # Pipeline: cargo build -> cbindgen -> patch header -> hs-bindgen
# #
# Prerequisites: run inside the Nix dev shell (provides gcc, cabal, etc.) # Prerequisites: run inside the Nix dev shell (provides gcc, cabal, cbindgen, hs-bindgen-cli).
# cbindgen is fetched via `nix run nixpkgs#rust-cbindgen`.
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
RUST_DIR="$SCRIPT_DIR/rust" RUST_DIR="$SCRIPT_DIR/rust"
@ -22,7 +21,7 @@ cargo build --manifest-path "$RUST_DIR/Cargo.toml"
# --- Step 2: Generate C header with cbindgen --- # --- Step 2: Generate C header with cbindgen ---
echo "=== Running cbindgen ===" echo "=== Running cbindgen ==="
nix run nixpkgs#rust-cbindgen -- \ cbindgen \
--lang c \ --lang c \
--crate garnet-rs \ --crate garnet-rs \
--output "$HEADER" \ --output "$HEADER" \
@ -116,7 +115,7 @@ fi
# --- Step 5: Run hs-bindgen --- # --- Step 5: Run hs-bindgen ---
echo "=== Running hs-bindgen ===" echo "=== Running hs-bindgen ==="
cabal run -- hs-bindgen-cli preprocess \ hs-bindgen-cli preprocess \
--overwrite-files --create-output-dirs \ --overwrite-files --create-output-dirs \
--unique-id com.garnet --enable-record-dot \ --unique-id com.garnet --enable-record-dot \
--hs-output-dir "$HASKELL_DIR/generated" --module GarnetRs \ --hs-output-dir "$HASKELL_DIR/generated" --module GarnetRs \