about summary refs log tree commit diff
path: root/users/kranzes/wasm-hello-world/default.nix
diff options
context:
space:
mode:
authorIlan Joselevich <personal@ilanjoselevich.com>2024-06-18T18·03+0300
committerIlan Joselevich <personal@ilanjoselevich.com>2024-07-01T19·25+0000
commit7f8da5e6a9926170be2fefc1db847166e5631f16 (patch)
treed1d1593d89eecf8fba80e59d9cedefd559be6a5c /users/kranzes/wasm-hello-world/default.nix
parent4b2f3c5454a249c6fbd7697a5297c6d4db92ef3e (diff)
feat(users/kranzes): add wasm-hello-world r/8338
This can be used as a reference for how to build a wasm project with
crate2nix.

Change-Id: Ib4d0db6bf24d8f1dec4734d5f1e8de19212a54cd
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11859
Reviewed-by: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
Diffstat (limited to 'users/kranzes/wasm-hello-world/default.nix')
-rw-r--r--users/kranzes/wasm-hello-world/default.nix15
1 files changed, 15 insertions, 0 deletions
diff --git a/users/kranzes/wasm-hello-world/default.nix b/users/kranzes/wasm-hello-world/default.nix
new file mode 100644
index 000000000000..0970f955deff
--- /dev/null
+++ b/users/kranzes/wasm-hello-world/default.nix
@@ -0,0 +1,15 @@
+{ pkgs, lib, ... }:
+
+(pkgs.pkgsCross.wasm32-unknown-none.callPackage ./Cargo.nix { }).rootCrate.build.overrideAttrs (oldAttrs: {
+  installPhase = ''
+    ${lib.getExe pkgs.wasm-bindgen-cli} \
+      --target web \
+      --out-dir $out \
+      --out-name ${oldAttrs.crateName} \
+      --no-typescript \
+      target/lib/${oldAttrs.crateName}-${oldAttrs.metadata}.wasm
+
+      mv src/*.html $out
+  '';
+})
+