-
Notifications
You must be signed in to change notification settings - Fork 131
Expand file tree
/
Copy pathflake.nix
More file actions
54 lines (52 loc) · 2.25 KB
/
flake.nix
File metadata and controls
54 lines (52 loc) · 2.25 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
{
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
};
};
outputs = { nixpkgs, flake-utils, rust-overlay, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs {
inherit system overlays;
};
rustToolchain = pkgs.pkgsBuildHost.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
wasiSdk = pkgs.runCommand "wasi-sdk-24" {
buildInputs = with pkgs; [ gnutar llvmPackages_latest.clang-unwrapped binutils coreutils ];
} ''
wasi_tar=${pkgs.fetchurl {
url = "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-24/wasi-sdk-24.0-x86_64-linux.tar.gz";
sha256 = "sha256-xsOKq1bl3oit9sHrycOujacviOwrZW+wJO2o1BZ6C8U=";
}}
${pkgs.gnutar}/bin/tar xvfz $wasi_tar
${pkgs.coreutils}/bin/ln -fs ${pkgs.llvmPackages_latest.clang-unwrapped}/bin/clang wasi-sdk-24.0-x86_64-linux/bin/clang
${pkgs.coreutils}/bin/ln -fs ${pkgs.binutils}/bin/ar wasi-sdk-24.0-x86_64-linux/bin/ar
mv wasi-sdk-24.0-x86_64-linux $out
'';
in
{
devShells.default = pkgs.mkShell {
packages = with pkgs; [
wasiSdk
rustToolchain
wasmtime
llvmPackages_latest.libclang
];
shellHook = ''
export WASI_SDK=${wasiSdk}
'';
BINDGEN_EXTRA_CLANG_ARGS = builtins.concatStringsSep " " [
"-isystem ${pkgs.llvmPackages_latest.libclang.lib}/lib/clang/${pkgs.llvmPackages_latest.libclang.version}/include"
"-isystem ${pkgs.glibc.dev}/include"
];
# rquickjs automatically installs the WASI SDK.
BINDGEN_EXTRA_CLANG_ARGS_wasm32_wasip1 = "";
BINDGEN_EXTRA_CLANG_ARGS_wasm32_wasip2 = "";
LIBCLANG_PATH = "${pkgs.llvmPackages_latest.libclang.lib}/lib";
};
});
}