feat: Added wasm build target in flake.nix
This commit is contained in:
@@ -30,54 +30,35 @@
|
||||
};
|
||||
inherit (pkgs) lib;
|
||||
|
||||
stableToolchain = pkgs.rust-bin.stable.latest.default;
|
||||
stableToolchain = pkgs.rust-bin.stable.latest.default.override {
|
||||
targets = [
|
||||
"wasm32-unknown-unknown"
|
||||
];
|
||||
};
|
||||
stableToolchainWithRustAnalyzer = pkgs.rust-bin.stable.latest.default.override {
|
||||
extensions = ["rust-src" "rust-analyzer"];
|
||||
# Extra targets if required
|
||||
targets = [
|
||||
"wasm32-unknown-unknown"
|
||||
# "x86_64-unknown-linux-gnu"
|
||||
# "x86_64-unknown-linux-musl"
|
||||
# "x86_64-apple-darwin"
|
||||
# "aarch64-apple-darwin"
|
||||
];
|
||||
};
|
||||
craneLib = (crane.mkLib pkgs).overrideToolchain stableToolchain;
|
||||
src = craneLib.cleanCargoSource (craneLib.path ./.);
|
||||
commonArgs = {
|
||||
inherit src;
|
||||
buildInputs = with pkgs;
|
||||
[
|
||||
# alsa-lib
|
||||
# wayland
|
||||
# xorg.libX11
|
||||
# xorg.libXi
|
||||
# libGL
|
||||
[]
|
||||
++ pkgs.lib.optionals pkgs.stdenv.isLinux [
|
||||
alsa-lib
|
||||
]
|
||||
++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
|
||||
pkgs.darwin.apple_sdk.frameworks.Foundation
|
||||
pkgs.darwin.apple_sdk.frameworks.CoreServices
|
||||
pkgs.darwin.apple_sdk.frameworks.Security
|
||||
pkgs.darwin.apple_sdk.frameworks.SystemConfiguration
|
||||
pkgs.darwin.apple_sdk.frameworks.System
|
||||
pkgs.darwin.apple_sdk.frameworks.ImageIO
|
||||
pkgs.darwin.apple_sdk.frameworks.AppKit
|
||||
pkgs.darwin.apple_sdk.frameworks.Vision
|
||||
pkgs.darwin.apple_sdk.frameworks.CoreGraphics
|
||||
pkgs.darwin.apple_sdk.frameworks.Metal
|
||||
pkgs.darwin.apple_sdk.frameworks.AVFoundation
|
||||
pkgs.darwin.apple_sdk.frameworks.MetalKit
|
||||
# "-lsystem" "-framework" "Foundation" "-framework" "ImageIO" "-framework" "AppKit" "-framework" "Vision" "-framework" "CoreGraphics" "-framework" "Metal" "-framework" "AVFoundation" "-framework" "CoreMidi" "-framework" "MetalKit" "-lobjc" "-liconv" "-lSystem" "-lc" "-lm"
|
||||
]; # Inputs required for the TARGET system
|
||||
];
|
||||
|
||||
nativeBuildInputs = with pkgs; [
|
||||
# often required for c/c++ libs
|
||||
pkg-config
|
||||
]; # Intputs required for the HOST system
|
||||
# This is often requird for any ffi based packages that use bindgen
|
||||
# LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
|
||||
# For using pkg-config that many libraries require
|
||||
# PKG_CONFIG_PATH = lib.makeSearchPath "lib/pkgconfig" (with pkgs;[ openssl.dev zlib.dev ]);
|
||||
];
|
||||
};
|
||||
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
|
||||
in {
|
||||
@@ -126,6 +107,11 @@
|
||||
'';
|
||||
})
|
||||
else tadventure-unwrapped;
|
||||
tadventure-wasm = craneLib.buildPackage {
|
||||
inherit src;
|
||||
doCheck = false;
|
||||
cargoExtraArgs = "--target wasm32-unknown-unknown";
|
||||
};
|
||||
default = tadventure;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user