about summary refs log tree commit diff
path: root/corp/russian/predlozhnik/default.nix
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2023-01-17T18·20+0300
committerclbot <clbot@tvl.fyi>2023-01-17T18·23+0000
commitaa96e25bbc96d81ffe546ffac76d9b04bef12811 (patch)
tree9bdf45a782974d8374cdc95d7ec6bbca59cee537 /corp/russian/predlozhnik/default.nix
parent0cbdfffea22eb0bad38dad6f91f1c6f8e445651f (diff)
chore(tazjin/predlozhnik): move to //corp r/5678
This is currently hosted by the company, and I'm assigning my
copyright to the company, which also runs an ad placement on the page.

Note that the NixOS module for hosting it has not been moved yet.

Change-Id: Iba9e1cab9370faa79e43c3344fbfbbbabead50b3
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7857
Reviewed-by: tazjin <tazjin@tvl.su>
Autosubmit: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
Diffstat (limited to 'corp/russian/predlozhnik/default.nix')
-rw-r--r--corp/russian/predlozhnik/default.nix52
1 files changed, 52 insertions, 0 deletions
diff --git a/corp/russian/predlozhnik/default.nix b/corp/russian/predlozhnik/default.nix
new file mode 100644
index 000000000000..2137be111278
--- /dev/null
+++ b/corp/russian/predlozhnik/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 = "predlozhnik";
+  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;
+}