forked from EasyTier/EasyTier
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
121 lines (114 loc) · 3.59 KB
/
flake.nix
File metadata and controls
121 lines (114 loc) · 3.59 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
{
description = "EasyTier development environment";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{
self,
nixpkgs,
flake-utils,
rust-overlay,
...
}:
flake-utils.lib.eachDefaultSystem (
system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs {
inherit system overlays;
config = {
licenseAccepted = true;
allowUnfree = true;
};
};
rustVersion = "1.93.0";
makeRust =
features:
let
rustTarget = pkgs.stdenv.hostPlatform.config;
muslTarget = pkgs.lib.replaceStrings [ "gnu" ] [ "musl" ] rustTarget;
muslTargets = if pkgs.stdenv.isLinux then [ muslTarget ] else [ ];
in
pkgs.rust-bin.stable.${rustVersion}.default.override {
extensions = [
"rust-src"
"rust-analyzer"
]
++ (if builtins.elem "android" features then android.rust.extensions else [ ]);
targets = muslTargets ++ (if builtins.elem "android" features then android.rust.targets else []);
};
android = import ./android.nix {
inherit pkgs system nixpkgs;
};
makeShell =
features:
let
hasFeature = feature: builtins.elem feature features;
withFeature = feature: pkgList: if hasFeature feature then pkgList else [ ];
flattenPaths = xs: builtins.concatLists (map (p: if builtins.isList p then p else [ p ]) xs);
rust = makeRust features;
in
pkgs.mkShell (rec {
nativeBuildInputs =
with pkgs;
(
[
rust
protobuf
clang
pkg-config
bridge-utils # for three node test
]
++ (withFeature "web" [
nodejs_22
pnpm
])
++ (withFeature "gui" [
libayatana-appindicator
])
++ (withFeature "android" android.packages)
);
buildInputs = with pkgs; ([
jemalloc
zstd
openssl
libclang
llvmPackages.libclang
libsoup_3
webkitgtk_4_1
]);
RUST_SRC_PATH = "${rust}/lib/rustlib/src/rust/library";
LIBCLANG_PATH = "${pkgs.libclang.lib}/lib";
BINDGEN_EXTRA_CLANG_ARGS = "-I${pkgs.clang}/resource-root/include";
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath (flattenPaths (buildInputs ++ nativeBuildInputs));
ZSTD_SYS_USE_PKG_CONFIG = true;
KCP_SYS_EXTRA_HEADER_PATH = "${pkgs.libclang.lib}/lib/clang/19/include:${pkgs.glibc.dev}/include";
JEMALLOC_OVERRIDE = "${pkgs.jemalloc}/lib/libjemalloc.so";
}
// (if hasFeature "android" then android.envVars else { }));
in
{
devShells = {
default = makeShell [ ];
core = makeShell [ ];
web = makeShell [ "web" ];
gui = makeShell [ "gui" "web" ];
android = makeShell [
"android"
"web"
];
full = makeShell [
"web"
"gui"
"android"
];
};
}
);
}