Move Rust build into its own flake at rust/flake.nix using crane, and reference it as an input from the top-level flake. The Haskell build gets the Rust artifacts (header + static lib) via a haskell.nix override that symlinks them into place before configure. Use Cabal's Cgarnet_rs naming convention for extra-bundled-libraries to satisfy the shared library install phase naming requirements. Also extract inputs.nix, default.nix, and shell.nix for flake-compat (nix-build / nix-shell) support.
55 lines
1.8 KiB
Nix
55 lines
1.8 KiB
Nix
{ inputs ? (import ./inputs.nix)
|
|
, garnet-rs ? inputs.garnet-rs.packages.${system}.default
|
|
}:
|
|
|
|
{
|
|
name = "garnet";
|
|
src = ./.;
|
|
compiler-nix-name = "ghc914";
|
|
source-repository-packages = {
|
|
# not on Hackage yet: https://well-typed.com/blog/2026/02/hs-bindgen-alpha
|
|
# we're using more recent versions than in that post, because we want record-dot support:
|
|
# https://github.com/well-typed/hs-bindgen/issues/1829#issuecomment-4081875451
|
|
c-expr-dsl = inputs.hs-bindgen-src + "/c-expr-dsl";
|
|
c-expr-runtime = inputs.hs-bindgen-src + "/c-expr-runtime";
|
|
hs-bindgen = inputs.hs-bindgen-src + "/hs-bindgen";
|
|
hs-bindgen-runtime = inputs.hs-bindgen-src + "/hs-bindgen-runtime";
|
|
libclang-bindings = inputs.libclang-src;
|
|
};
|
|
overrides = [
|
|
({ pkgs, ... }: {
|
|
packages.libclang-bindings.components.library = {
|
|
build-tools = [ pkgs.llvmPackages.llvm ];
|
|
libs = [ pkgs.llvmPackages.libclang ];
|
|
};
|
|
})
|
|
] ++ (if garnet-rs != null then [
|
|
(_: {
|
|
packages.garnet.components.library = {
|
|
preConfigure = ''
|
|
mkdir -p rust/target/debug
|
|
ln -s ${garnet-rs}/include/garnet_rs.h rust/target/debug/garnet_rs.h
|
|
ln -s ${garnet-rs}/lib/libCgarnet_rs.a rust/target/debug/libCgarnet_rs.a
|
|
'';
|
|
preInstall = ''
|
|
cp ${garnet-rs}/lib/libCgarnet_rs.a dist/build/libCgarnet_rs.a
|
|
'';
|
|
configureFlags = [ "--extra-lib-dirs=${garnet-rs}/lib" ];
|
|
};
|
|
})
|
|
] else []);
|
|
shell = {
|
|
tools = {
|
|
cabal = "latest";
|
|
haskell-language-server = {
|
|
src = inputs.hls-src;
|
|
sha256map = {
|
|
"https://github.com/snowleopard/alga"."d4e43fb42db05413459fb2df493361d5a666588a" = "0s1mlnl64wj7pkg3iipv5bb4syy3bhxwqzqv93zqlvkyfn64015i";
|
|
};
|
|
};
|
|
};
|
|
withHoogle = false;
|
|
withHaddock = true;
|
|
};
|
|
}
|