-
Notifications
You must be signed in to change notification settings - Fork 57
/
flake.nix
142 lines (124 loc) · 4.54 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
};
outputs = { self, nixpkgs, flake-utils, fenix, ... }:
let
# buildTargets = {
# "x86_64-linux" = {
# crossSystemConfig = "x86_64-unknown-linux-musl";
# rustTarget = "x86_64-unknown-linux-musl";
# };
# "aarch64-linux" = {
# crossSystemConfig = "x86_64-unknown-linux-musl";
# rustTarget = "x86_64-unknown-linux-musl";
# };
# "aarch64-darwin" = {};
# "wasm" = {
# crossSystemConfig = "wasm32-unknown-unknown";
# rustTarget = "wasm32-unknown-unknown";
# makeBuildPackageAttrs = pkgsCross: {
# OPENSSL_STATIC = null;
# OPENSSL_LIB_DIR = null;
# OPENSSL_INCLUDE_DIR = null;
# };
# };
# };
# mkPkgs = buildSystem: targetSystem: import nixpkgs ({
# system = buildSystem;
# } // (if targetSystem == null then {} else {
# crossSystemcnofig = buildTargets.${targetSystem}.crossSystemConfig;
# }));
# eachSystem = supportedSystems: callback: builtins.fold'
# (overall: system: overall // { ${system} = callback system; })
# {}
# supportedSystems;
in
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
clang = pkgs.llvmPackages_19.clang;
pythonEnv = pkgs.python3.withPackages (ps: []);
toolchain = with fenix.packages.${system}; combine [
minimal.cargo
minimal.rustc
latest.rust-std
];
version = (builtins.fromTOML (builtins.readFile ./engine/Cargo.toml)).workspace.package.version;
appleDeps = with pkgs.darwin.apple_sdk.frameworks; [
CoreServices
SystemConfiguration
pkgs.libiconv-darwin
];
rustPlatform = pkgs.makeRustPlatform {
inherit (fenix.packages.${system}.minimal) cargo rustc;
inherit (fenix.packages.${system}.latest) rust-std;
};
in
{
packages.default = rustPlatform.buildRustPackage {
pname = "baml-cli";
version = version;
src = let
extraFiles = pkgs.copyPathToStore ./engine/baml-runtime/src/cli/initial_project/baml_src;
in pkgs.symlinkJoin {
name = "source";
paths = [ ./engine extraFiles ];
};
LIBCLANG_PATH = pkgs.libclang.lib + "/lib/";
BINDGEN_EXTRA_CLANG_ARGS = if pkgs.stdenv.isDarwin then
"-I${pkgs.llvmPackages_19.libclang.lib}/lib/clang/19/headers "
else
"-isystem ${pkgs.llvmPackages_19.libclang.lib}/lib/clang/19/include -isystem ${pkgs.glibc.dev}/include";
cargoLock = { lockFile = ./engine/Cargo.lock; outputHashes = {
"pyo3-asyncio-0.21.0" = "sha256-5ZLzWkxp3e2u0B4+/JJTwO9SYKhtmBpMBiyIsTCW5Zw=";
"serde_magnus-0.9.0" = "sha256-+iIHleftJ+Yl9QHEBVI91NOhBw9qtUZfgooHKoyY1w4=";
}; };
# Add build-time environment variables
RUSTFLAGS = "-C target-feature=+crt-static --cfg tracing_unstable";
# Modify the test phase to only run library tests
checkPhase = ''
runHook preCheck
echo "Running cargo test --lib"
cargo test --lib
runHook postCheck
'';
buildInputs = (with pkgs; [
openssl
pkg-config
lld_19
pythonEnv
ruby
maturin
nodePackages.pnpm
nodePackages.nodejs
]) ++ (if pkgs.stdenv.isDarwin then appleDeps else []);
nativeBuildInputs = [
pkgs.openssl
pkgs.pkg-config
pkgs.ruby
pythonEnv
pkgs.maturin
];
PYTHON_SYS_EXECUTABLE="${pythonEnv}/bin/python3";
LD_LIBRARY_PATH="${pythonEnv}/lib";
PYTHONPATH="${pythonEnv}/${pythonEnv.sitePackages}";
CC="${clang}/bin/clang";
};
devShell = pkgs.mkShell rec {
buildInputs = [toolchain];
PATH="${clang}/bin:$PATH";
LIBCLANG_PATH = pkgs.libclang.lib + "/lib/";
};
}
);
}