This repository has no description
1.8 kB
76 lines
1{
2 lib,
3 rustPlatform,
4 fetchFromGitHub,
5 fetchCrate,
6 buildWasmBindgenCli,
7 trunk,
8 binaryen,
9 llvmPackages,
10}:
11
12let
13 # trunk refuses to run a wasm-bindgen whose version differs from the one in
14 # Cargo.lock, and nixpkgs only ships up to 0.2.127.
15 wasm-bindgen-cli = buildWasmBindgenCli rec {
16 src = fetchCrate {
17 pname = "wasm-bindgen-cli";
18 version = "0.2.129";
19 hash = "sha256-pcecKQd7E8Opw6bkFoE569epUi7gh5qpQF1e5PJY6V8=";
20 };
21
22 cargoDeps = rustPlatform.fetchCargoVendor {
23 inherit src;
24 inherit (src) pname version;
25 hash = "sha256-vmUrWVU7kPJJxO5qIVeAkwQyWDELO1Z4Z5gitz2kco8=";
26 };
27 };
28in
29rustPlatform.buildRustPackage (finalAttrs: {
30 pname = "photocraft-web";
31 version = "0.1.1";
32
33 src = fetchFromGitHub {
34 owner = "storytold";
35 repo = "photocraft";
36 tag = "v${finalAttrs.version}";
37 hash = "sha256-lyhQ+kewBiZSNx/w/e6RO4dTKZmDD5hnsDSEKkKrtt0=";
38 };
39
40 cargoHash = "sha256-MLECpUx0J0RjxHXbhhR1WK8iajiNU+gJeZBsyZZwxg4=";
41
42 nativeBuildInputs = [
43 trunk
44 wasm-bindgen-cli
45 binaryen
46 llvmPackages.bintools-unwrapped
47 ];
48
49 # Shown in Help › About (crates/engine/src/build_info.rs).
50 env.PHOTOCRAFT_BUILD_SHA = finalAttrs.src.tag;
51
52 buildPhase = ''
53 runHook preBuild
54 (cd apps/photocraft-web && HOME=$TMPDIR trunk build --offline --frozen --release)
55 runHook postBuild
56 '';
57
58 # The test suite targets the native workspace, not the wasm bundle.
59 doCheck = false;
60
61 installPhase = ''
62 runHook preInstall
63 cp -r dist/web $out
64 runHook postInstall
65 '';
66
67 meta = {
68 description = "PhotoCraft image editor compiled to WebAssembly, as a static site";
69 homepage = "https://getartcraft.com/apps/photocraft";
70 license = with lib.licenses; [
71 mit
72 asl20
73 ];
74 platforms = lib.platforms.all;
75 };
76})