garnet/flake.nix

59 lines
2.1 KiB
Nix
Raw Normal View History

2026-02-17 14:57:34 +00:00
{
inputs = {
nix-haskell.url = "github:reflex-frp/nix-haskell";
2026-03-25 12:36:52 +00:00
nixpkgs.follows = "nix-haskell/nixpkgs";
hls-src = { url = "github:haskell/haskell-language-server/2.13.0.0"; flake = false; };
hs-bindgen-src = { url = "github:well-typed/hs-bindgen/release-0.1-alpha2"; flake = false; };
libclang-src = { url = "github:well-typed/libclang"; flake = false; };
2026-02-17 14:57:34 +00:00
flake-utils.url = "github:numtide/flake-utils";
crane.url = "github:ipetkov/crane";
rust-overlay = {
url = "github:oxalica/rust-overlay";
2026-03-25 12:36:52 +00:00
inputs.nixpkgs.follows = "nixpkgs";
2026-02-17 14:57:34 +00:00
};
};
outputs =
inputs@{ nix-haskell, ... }:
2026-02-19 13:58:58 +00:00
inputs.flake-utils.lib.eachSystem [ "x86_64-linux" ] (system:
2026-02-17 14:57:34 +00:00
let
2026-03-25 12:36:52 +00:00
pkgs = haskell.nixpkgs.extend (import inputs.rust-overlay);
nix-haskell = import inputs.nix-haskell { inherit system inputs; };
crane = (inputs.crane.mkLib pkgs).overrideToolchain (p: p.rust-bin.selectLatestNightlyWith (
2026-02-17 14:57:34 +00:00
toolchain: toolchain.default.override {
extensions = [ "rust-src" ];
targets = [ "x86_64-unknown-linux-gnu" ];
}
));
2026-03-25 12:36:52 +00:00
haskell =
nix-haskell (import ./project.nix { inherit (inputs) hls-src hs-bindgen-src libclang-src; inherit garnet-rs; });
garnet-rs = crane.buildPackage {
src = crane.cleanCargoSource ./rust;
doCheck = false;
installPhaseCommand = ''
mkdir -p $out/lib $out/include
cp target/release/libgarnet_rs.a $out/lib/libCgarnet_rs.a
cp target/release/garnet_rs.h $out/include/
'';
};
2026-02-17 14:57:34 +00:00
in
2026-03-25 12:36:52 +00:00
rec {
defaultPackage = packages.garnet-exe;
packages = let garnet = haskell.project.haskell-nix.hsPkgs.garnet; in {
inherit garnet-rs;
garnet-exe = garnet.components.exes.garnet;
garnet-lib = garnet.components.library;
};
2026-02-17 14:57:34 +00:00
devShells.default = pkgs.mkShell {
inputsFrom = [
2026-03-25 12:36:52 +00:00
haskell.project.haskell-nix.shell
(crane.devShell { })
2026-02-17 14:57:34 +00:00
];
packages = with pkgs; [
bacon
ghcid
rust-analyzer
];
};
2026-02-19 13:59:19 +00:00
});
2026-02-17 14:57:34 +00:00
}