forked from Rikorose/DeepFilterNet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
127 lines (108 loc) · 3.13 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
{
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";
};
crane = {
url = "github:ipetkov/crane";
};
};
outputs =
{ self
, nixpkgs
, flake-utils
, rust-overlay
, crane
}:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; overlays = [ (import rust-overlay) ]; };
rust-toolchain = (pkgs.rust-bin.stable.latest.default).override {
extensions = [ "rust-analyzer" "rust-src" ];
targets = [ "wasm32-unknown-unknown" ];
};
craneLib = (crane.mkLib nixpkgs.legacyPackages.${system}).overrideToolchain rust-toolchain;
python = pkgs.python312;
coreAudio =
if pkgs.stdenv.isDarwin then
# pkgs.symlinkJoin
pkgs.buildEnv
{
name = "sdk";
paths = with pkgs.darwin.apple_sdk.frameworks; [
CoreFoundation
CoreServices
SystemConfiguration
Security
AudioToolbox
AudioUnit
CoreAudio
CoreFoundation
CoreMIDI
OpenAL
];
postBuild = ''
# mkdir $out/System
ln -s $out/Library $out/System
'';
}
else
"";
buildInputs = {
nativeBuildInputs = with pkgs; [
rust-toolchain
pkg-config
lld
wasm-pack
binaryen # wasm-opt
python
wasm-bindgen-cli
];
buildInputs = with pkgs; [
openssl
clang
] ++ (if pkgs.stdenv.isDarwin then [ libiconv coreAudio ] else [ alsa-lib ]);
wasm-bindgen-cli = pkgs.wasm-bindgen-cli;
};
cargoExtraArgs = "-p deep_filter --no-default-features --features wasm,default-model --target wasm32-unknown-unknown";
libDF-deps = craneLib.buildDepsOnly (buildInputs // {
pname = "libDF-deps";
cargoToml = ./libDF/Cargo.toml;
src = ./.;
doCheck = false;
inherit cargoExtraArgs;
});
libDF = craneLib.buildPackage (buildInputs // {
cargoToml = ./libDF/Cargo.toml;
src = ./.;
doCheck = false;
cargoArtifacts = libDF-deps;
inherit cargoExtraArgs;
doNotPostBuildInstallCargoBinaries = true;
buildPhaseCargoCommand = ''
export XDG_CACHE_HOME=$(mktemp -d)
export HOME=$XDG_CACHE_HOME
sh ./scripts/build_wasm_package.sh
'';
installPhaseCommand = ''
mkdir -p $out/
cp -r libDF/pkg/* $out/
'';
});
shell = pkgs.mkShell {
inputsFrom = [ libDF ];
packages = with pkgs; [ miniserve ];
RUST_BACKTRACE = "1";
RUST_LOG = "info";
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
};
in
{
devShells.default = shell;
packages = { inherit libDF; };
}
);
}