2026-02-17 14:57:34 +00:00
|
|
|
cabal-version: 3.0
|
|
|
|
|
name: garnet
|
|
|
|
|
version: 0.1.0.0
|
2026-02-19 13:53:18 +00:00
|
|
|
license: BSD-3-Clause
|
2026-02-17 14:57:34 +00:00
|
|
|
author: Patrick Aldis
|
2026-02-19 13:53:18 +00:00
|
|
|
maintainer:
|
|
|
|
|
george.thomas@obsidian.systems
|
|
|
|
|
patrick.aldis@obsidian.systems
|
2026-02-17 14:57:34 +00:00
|
|
|
|
|
|
|
|
executable garnet
|
|
|
|
|
main-is: Main.hs
|
|
|
|
|
hs-source-dirs: .
|
|
|
|
|
other-modules:
|
|
|
|
|
default-language: GHC2024
|
|
|
|
|
default-extensions:
|
|
|
|
|
BlockArguments
|
|
|
|
|
DeriveAnyClass
|
|
|
|
|
DuplicateRecordFields
|
|
|
|
|
ImpredicativeTypes
|
|
|
|
|
LexicalNegation
|
|
|
|
|
MultiWayIf
|
|
|
|
|
NamedFieldPuns
|
|
|
|
|
NegativeLiterals
|
|
|
|
|
NoFieldSelectors
|
|
|
|
|
NoMonomorphismRestriction
|
|
|
|
|
OverloadedRecordDot
|
|
|
|
|
OverloadedStrings
|
|
|
|
|
RecordWildCards
|
|
|
|
|
ViewPatterns
|
|
|
|
|
ghc-options:
|
|
|
|
|
-Wall
|
|
|
|
|
-fdefer-type-errors
|
|
|
|
|
-threaded
|
|
|
|
|
-rtsopts
|
|
|
|
|
-with-rtsopts=-N
|
Call Rust from Haskell with `cargo-cabal` and `hs-bindgen`
See https://sraka.xyz/posts/hs-bindgen-introduction.html.
For now, this is a shell-based workflow, rather than using Nix to build everything, i.e. `nix develop` works but `nix build` doesn't. And `cargo build` has to be called manually to create the C library, rather than `cabal` being clever enough to invoke it itself.
We ran `cargo cabal init` from the `rust` directory (`nix shell github:yvan-sraka/cargo-cabal`), which generated `hsbindgen.toml` (which we use), and `Setup.lhs` (which just added `extra-lib-dirs`, and with the wrong paths, so we dspecify those statically instead in `garnet.cabal`). We also follow its advice to use `staticlib`.
Also, after we ran the first `cargo build` (requiring a `mkdir rust/src` before it would run), we took the generated the Haskell file, and moved the main contents in to `Main.hs` manually.
2026-02-18 15:49:08 +00:00
|
|
|
extra-lib-dirs:
|
|
|
|
|
-- TODO referring to parent triggers warning - maybe put Rust stuff in subdir
|
|
|
|
|
-- TODO bit weird to have both of these, but it's what the `cargo-cabal` setup script did
|
|
|
|
|
../rust/target/release
|
|
|
|
|
../rust/target/debug
|
|
|
|
|
extra-bundled-libraries: garnet_rs
|
2026-02-17 14:57:34 +00:00
|
|
|
build-depends:
|
|
|
|
|
base >= 4.14,
|