summaryrefslogtreecommitdiff
path: root/flake.nix
diff options
context:
space:
mode:
authorTom Barrett <tom@tombarrett.xyz>2024-01-14 17:53:28 +0100
committerTom Barrett <tom@tombarrett.xyz>2024-01-14 17:53:28 +0100
commit0375faa9670737191d0c276f3b5daf83a6cfc8e8 (patch)
tree374735bcd68f92d4f144e67e5fe89fcce80d6931 /flake.nix
parent79c1c693130369e115c316c2f149ed5a1c2cdc03 (diff)
flake to build wasmHEADmaster
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix41
1 files changed, 41 insertions, 0 deletions
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..e418992
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,41 @@
+{
+ outputs = {
+ self,
+ nixpkgs,
+ }: let
+ pkgs = nixpkgs.legacyPackages.x86_64-linux;
+ buildRustPackage =
+ pkgs.rustPlatform.buildRustPackage.override
+ {rustc = pkgs.rustc-wasm32;};
+ rust-lld = pkgs.symlinkJoin {
+ name = "rust-lld";
+ paths = [pkgs.rustc-wasm32.llvmPackages.lld];
+ postBuild = ''
+ ln -s $out/bin/lld $out/bin/rust-lld
+ '';
+ };
+ in {
+ packages.x86_64-linux.default = buildRustPackage rec {
+ name = "gems";
+ src = ./.;
+ cargoLock = {
+ lockFile = ./Cargo.lock;
+ };
+ doCheck = false;
+ buildPhase = ''
+ cargo build --target wasm32-unknown-unknown --release
+ wasm-bindgen --out-name gems \
+ --out-dir $out \
+ --target web target/wasm32-unknown-unknown/release/gems.wasm
+ '';
+ installPhase = ''
+ cp -r assets $out
+ cp index.html $out
+ '';
+ nativeBuildInputs = [
+ rust-lld
+ pkgs.wasm-bindgen-cli
+ ];
+ };
+ };
+}