-
Notifications
You must be signed in to change notification settings - Fork 78
Expand file tree
/
Copy pathflake.nix
More file actions
121 lines (119 loc) · 4.43 KB
/
flake.nix
File metadata and controls
121 lines (119 loc) · 4.43 KB
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
# Flake Shell for building release artifacts for swift and kotlin
{
nixConfig = {
http-connections = 128;
max-substitution-jobs = 128;
};
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
fenix = {
url = "github:nix-community/fenix";
inputs = {
nixpkgs.follows = "nixpkgs";
};
};
flake-parts = {
url = "github:hercules-ci/flake-parts";
};
foundry.url = "github:shazow/foundry.nix/stable";
crane = {
url = "github:ipetkov/crane";
};
rust-flake.url = "github:juspay/rust-flake";
rust-manifest = {
url = "https://static.rust-lang.org/dist/channel-rust-1.92.0.toml";
flake = false;
};
treefmt-nix.url = "github:numtide/treefmt-nix";
};
outputs =
inputs@{ flake-parts, self, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [
"aarch64-darwin"
"x86_64-linux"
"aarch64-linux"
];
imports = [
./nix/lib
flake-parts.flakeModules.easyOverlay
inputs.rust-flake.flakeModules.default
inputs.rust-flake.flakeModules.nixpkgs
inputs.treefmt-nix.flakeModule
./nix/rust-defaults.nix
./nix/rust.nix
./nix/musl-docker.nix
./nix/ci-checks.nix
./nix/fmt.nix
];
perSystem =
{ pkgs, lib, ... }:
{
nixpkgs = self.lib.pkgConfig;
devShells = {
# lib.mkForce overrides the devShells.rust auto-generated by rust-flake
rust = lib.mkForce (pkgs.callPackage ./nix/shells/rust.nix { });
default = pkgs.callPackage ./nix/shells/local.nix { };
android = pkgs.callPackage ./nix/shells/android.nix { };
js = pkgs.callPackage ./nix/js.nix { };
wasm = (pkgs.callPackage ./nix/package/wasm.nix { }).devShell;
}
// lib.optionalAttrs pkgs.stdenv.isDarwin {
ios = pkgs.callPackage ./nix/shells/ios.nix { };
};
packages =
let
android = pkgs.callPackage ./nix/package/android.nix { };
inherit (pkgs.xmtp) androidEnv;
in
{
inherit (pkgs.xmtp) ffi-uniffi-bindgen;
wasm-bindings = (pkgs.callPackage ./nix/package/wasm.nix { }).bin;
wasm-bindings-test = (pkgs.callPackage ./nix/package/wasm.nix { test = true; }).bin;
wasm-bindgen-cli = pkgs.callPackage ./nix/lib/packages/wasm-bindgen-cli.nix { };
# Android bindings (.so libraries + Kotlin bindings)
android-libs = android.aggregate;
# Android bindings - host-matching target only (fast dev/CI builds)
android-libs-fast = (android.mkAndroid [ androidEnv.hostAndroidTarget ]).aggregate;
}
// (
let
node = pkgs.callPackage ./nix/package/node.nix { };
inherit (pkgs.xmtp) nodeEnv;
in
# Expose per-target packages with NAPI platform names
lib.mapAttrs' (
triple: drv: lib.nameValuePair "node-bindings-${nodeEnv.targetToNapi.${triple}}" drv
) node.targets
// {
# Fast: host-matching target only
node-bindings-fast = node.buildTarget nodeEnv.hostTarget;
# JS/TS bindings (index.js + index.d.ts)
node-bindings-js = node.jsBindings;
}
)
// lib.optionalAttrs pkgs.stdenv.isDarwin {
# stdenvNoCC is passed to callPackage (for the aggregate derivation).
# This avoids Nix's apple-sdk and cc-wrapper,
# which inject -mmacos-version-min flags that
# conflict with iOS cross-compilation. The builds are impure (__noChroot)
# and use the system Xcode SDK directly via ios-env.nix paths.
ios-libs =
(pkgs.callPackage ./nix/package/ios.nix {
stdenv = pkgs.stdenvNoCC;
}).aggregate;
# iOS bindings - simulator + host macOS only (fast dev/CI builds)
ios-libs-fast =
(
(pkgs.callPackage ./nix/package/ios.nix {
stdenv = pkgs.stdenvNoCC;
}).mkIos
[
"aarch64-apple-darwin"
"aarch64-apple-ios-sim"
]
).aggregate;
};
};
};
}