forked from rupurt/zodbc
-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
92 lines (84 loc) · 2.68 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
{
description = "A blazing fast ODBC Zig client";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
zig-overlay = {
url = "github:mitchellh/zig-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
odbc-drivers = {
url = "github:rupurt/odbc-drivers-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {
flake-utils,
nixpkgs,
zig-overlay,
odbc-drivers,
...
}: let
systems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"];
outputs = flake-utils.lib.eachSystem systems (system: let
pkgs = import nixpkgs {
# NOTE:
# IBM currently only provides an x86_64 driver for Mac. An aarch64 native driver
# is scheduled for 2024 so this can be removed when it's released
# - https://ibm-data-and-ai.ideas.ibm.com/ideas/DB2CON-I-92
system =
if system == "aarch64-darwin"
then "x86_64-darwin"
else system;
overlays = [
zig-overlay.overlays.default
odbc-drivers.overlay
# WebUI fails to build on Linux with unexported symbol
# - emcc: error: undefined exported symbol: "__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9__grow_byEmmmmmm" [-Wundefined] [-Werror]
# (final: prev: {
# tree-sitter = prev.tree-sitter.override {webUISupport = true;};
# })
];
};
db2Driver =
if pkgs.stdenv.isLinux
then "${pkgs.odbc-driver-pkgs.db2-odbc-driver}/lib/libdb2o.so"
else "${pkgs.odbc-driver-pkgs.db2-odbc-driver}/lib/libdb2o.dylib";
postgresDriver =
if pkgs.stdenv.isLinux
then "${pkgs.odbc-driver-pkgs.postgres-odbc-driver}/lib/psqlodbca.so"
else "${pkgs.odbc-driver-pkgs.postgres-odbc-driver}/lib/psqlodbca.dylib";
in {
# packages exported by the flake
packages = {};
# nix run
apps = {};
# nix fmt
formatter = pkgs.alejandra;
# nix develop -c $SHELL
devShells.default = pkgs.mkShell {
name = "default dev shell";
buildInputs = [
pkgs.pkg-config
pkgs.zigpkgs.master
pkgs.unixODBC
pkgs.arrow-cpp
];
packages =
[
pkgs.odbc-driver-pkgs.db2-odbc-driver
pkgs.odbc-driver-pkgs.postgres-odbc-driver
pkgs.tracy
pkgs.tree-sitter
]
++ pkgs.lib.optionals (pkgs.stdenv.isLinux) [
pkgs.strace
pkgs.valgrind
];
DB2_DRIVER = db2Driver;
POSTGRES_DRIVER = postgresDriver;
};
});
in
outputs;
}