things I've changed from the PR: - dropped legacy (i.e. non-flake) compat stuff, which turns out to account for most of the diff - dropped `packages.garnet` since it doesn't work with `nix build .#garnet` - back to using Rust-extended packages everywhere, which _seems_ fine the rest is just re-inlining things and other refactors final question: it does seems a bit weird that `garnet-rs` arg to `project.nix` was always the same might be a mistake, and we're supposed to be using local for local build? "improve nix-haskell use" there are a few things going on here but the main ones are ... note that changes we keep are essentially: - bumping `nix-haskell` to avoid shell hook workaround - various changes in how we call `nix-haskell` - using `libCgarnet_rs` name, which Cabal expects - adding proper non-dev-shell targets, so that e.g. `nix run` works
55 lines
1.7 KiB
Nix
55 lines
1.7 KiB
Nix
{ hls-src
|
|
, hs-bindgen-src
|
|
, libclang-src
|
|
, garnet-rs
|
|
}:
|
|
{
|
|
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 = hs-bindgen-src + "/c-expr-dsl";
|
|
c-expr-runtime = hs-bindgen-src + "/c-expr-runtime";
|
|
hs-bindgen = hs-bindgen-src + "/hs-bindgen";
|
|
hs-bindgen-runtime = hs-bindgen-src + "/hs-bindgen-runtime";
|
|
libclang-bindings = libclang-src;
|
|
};
|
|
overrides = [
|
|
({ pkgs, ... }: {
|
|
packages.libclang-bindings.components.library = {
|
|
build-tools = [ pkgs.llvmPackages.llvm ];
|
|
libs = [ pkgs.llvmPackages.libclang ];
|
|
};
|
|
})
|
|
(_: {
|
|
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" ];
|
|
};
|
|
})
|
|
];
|
|
shell = {
|
|
tools = {
|
|
cabal = "latest";
|
|
haskell-language-server = {
|
|
src = hls-src;
|
|
sha256map = {
|
|
"https://github.com/snowleopard/alga"."d4e43fb42db05413459fb2df493361d5a666588a" = "0s1mlnl64wj7pkg3iipv5bb4syy3bhxwqzqv93zqlvkyfn64015i";
|
|
};
|
|
};
|
|
};
|
|
withHoogle = false;
|
|
withHaddock = true;
|
|
};
|
|
}
|