diff options
author | Vincent Ambo <mail@tazj.in> | 2023-06-06T11·26+0300 |
---|---|---|
committer | tazjin <tazjin@tvl.su> | 2023-06-06T11·43+0000 |
commit | 5dee4780dab5e22eb2929a3b4287c5a781fc20f9 (patch) | |
tree | efdbcdd87bef1bd6dcca3010c0b7115bb443b6de /corp/rih/frontend/default.nix | |
parent | 6fa6f3a7f4a72a74ce495609646d2dae3789cde3 (diff) |
chore(corp/rih): move frontend to a separate folder r/6237
Change-Id: Ic7467f459015c39c73f87c61a048319eaf1243be Reviewed-on: https://cl.tvl.fyi/c/depot/+/8714 Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su>
Diffstat (limited to 'corp/rih/frontend/default.nix')
-rw-r--r-- | corp/rih/frontend/default.nix | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/corp/rih/frontend/default.nix b/corp/rih/frontend/default.nix new file mode 100644 index 000000000000..24bbde09b975 --- /dev/null +++ b/corp/rih/frontend/default.nix @@ -0,0 +1,52 @@ +{ lib, pkgs, ... }: + +let + wasmRust = pkgs.rust-bin.stable.latest.default.override { + targets = [ "wasm32-unknown-unknown" ]; + }; + + cargoToml = with builtins; fromTOML (readFile ./Cargo.toml); + + wasmBindgenMatch = + cargoToml.dependencies.wasm-bindgen == "= ${pkgs.wasm-bindgen-cli.version}"; + + assertWasmBindgen = assert (lib.assertMsg wasmBindgenMatch '' + Due to instability in the Rust WASM ecosystem, the trunk build + tool enforces that the Cargo-dependency version of `wasm-bindgen` + MUST match the version of the CLI supplied in the environment. + + This can get out of sync when nixpkgs is updated. To resolve it, + wasm-bindgen must be bumped in the Cargo.toml file and cargo needs + to be run to resolve the dependencies. + + Versions of `wasm-bindgen` in Cargo.toml: + + Expected: '= ${pkgs.wasm-bindgen-cli.version}' + Actual: '${cargoToml.dependencies.wasm-bindgen}' + ''); pkgs.wasm-bindgen-cli; + + deps = with pkgs; [ + binaryen + sass + wasmRust + trunk + assertWasmBindgen + ]; + +in +pkgs.rustPlatform.buildRustPackage rec { + pname = "rih-frontend"; + version = "canon"; + src = lib.cleanSource ./.; + cargoLock.lockFile = ./Cargo.lock; + + buildPhase = '' + export PATH=${lib.makeBinPath deps}:$PATH + mkdir home + export HOME=$PWD/.home + env + trunk build --release -d $out + ''; + + dontInstall = true; +} |