about summary refs log tree commit diff
path: root/web/tvixbolt/default.nix
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@tvl.su>2024-02-23T08·00+0300
committerclbot <clbot@tvl.fyi>2024-02-23T08·08+0000
commit782cfa9e3372d0cfe13471597968d58deb181e71 (patch)
tree590d43f902e8ce560a26781732df87105a19b9e9 /web/tvixbolt/default.nix
parent91d5745c3dbb3eb118be969a80e0608794b0e59d (diff)
chore(tvixbolt): move from //corp to //web r/7595
Assigning copyright to the TVL community (whatever that is), and
adding AGPL-3.0-or-later license.

I also cleaned up some of the stuff on the landing page.

Change-Id: I4dbca19406e00e5105fed50e8fb64e0fcca23e3a
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11013
Autosubmit: tazjin <tazjin@tvl.su>
Reviewed-by: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
Diffstat (limited to 'web/tvixbolt/default.nix')
-rw-r--r--web/tvixbolt/default.nix74
1 files changed, 74 insertions, 0 deletions
diff --git a/web/tvixbolt/default.nix b/web/tvixbolt/default.nix
new file mode 100644
index 000000000000..9b6baa582fb0
--- /dev/null
+++ b/web/tvixbolt/default.nix
@@ -0,0 +1,74 @@
+{ depot, 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 = [
+    pkgs.binaryen
+    pkgs.sass
+    pkgs.trunk
+
+    wasmRust
+    assertWasmBindgen
+  ];
+
+  # Cargo.toml needs to be patched with the /nix/store source path of
+  # tvix-eval.
+  cargoTomlPatch = pkgs.writeText "tvix-eval-src.patch" ''
+    diff --git a/Cargo.toml b/Cargo.toml
+    index 75006bec18..6ca244bbb2 100644
+    --- a/Cargo.toml
+    +++ b/Cargo.toml
+    @@ -16,7 +16,7 @@ rnix = "0.11.0"
+     wasm-bindgen = "= 0.2.83"
+
+     [dependencies.tvix-eval]
+    -path = "../../tvix/eval"
+    +path = "${depot.tvix.crates.workspaceMembers.tvix-eval.build.src}"
+     default-features = false
+
+     [dependencies.serde]
+  '';
+in
+pkgs.rustPlatform.buildRustPackage rec {
+  pname = "tvixbolt";
+  version = "canon";
+  src = lib.cleanSource ./.;
+
+  cargoLock.lockFile = ./Cargo.lock;
+
+  patches = [
+    cargoTomlPatch
+  ];
+
+  buildPhase = ''
+    export PATH=${lib.makeBinPath deps}:$PATH
+    mkdir home
+    export HOME=$PWD/home
+    trunk build --release -d $out
+  '';
+
+  dontInstall = true;
+}