about summary refs log tree commit diff
path: root/web/tvixbolt/default.nix
blob: a3ce1662ff52e027645461453127d67b42fefdd7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
{ pkgs, lib, depot, ... }:
let
  pkgsCross = pkgs.pkgsCross.wasm32-unknown-none;
in
(pkgsCross.callPackage ./Cargo.nix {
  defaultCrateOverrides = (depot.tvix.utils.defaultCrateOverridesForPkgs pkgsCross) // {
    tvixbolt = prev: {
      src = depot.tvix.utils.filterRustCrateSrc { root = prev.src.origSrc; };
    };
  };
}).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,css} $out
  '';

  passthru.serve = pkgs.writeShellScriptBin "tvixbolt-serve" ''
    ${lib.getExe pkgs.simple-http-server} \
        --index \
        --nocache \
        "$@" \
        ${depot.web.tvixbolt}
  '';

  meta.ci.extraSteps.crate2nix-check = depot.tvix.utils.mkCrate2nixCheck ./Cargo.nix;
})