summaryrefslogtreecommitdiff
path: root/wage/default.nix
blob: bda492f69bcaf4886e22d6da0dddc3eddd7ede0e (plain)
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
33
34
35
36
37
38
39
40
{ rust
, wasm-bindgen-cli
, buildRustPackage
, fetchFromGitHub
}:

buildRustPackage {
  pname = "wage";
  version = "git-main";

  src = fetchFromGitHub {
    owner = "str4d";
    repo = "wage";
    rev = "refs/heads/main";
    sha256 = "sha256-ZeGYPIPAfYo+WGWtphfzcGtQ7qAjDslQoKcFhYyqEQM=";
  };

  nativeBuildInputs = [ rust wasm-bindgen-cli ];

  patchPhase = ''
    cp ${./Cargo.lock} .
  '';

  buildPhase = ''
    cargo build --release --target=wasm32-unknown-unknown
  '';

  installPhase = ''
    mkdir -p $out;

    wasm-bindgen \
      --target web \
      --out-dir $out \
      target/wasm32-unknown-unknown/release/wage.wasm;
  '';

  cargoLock = {
    lockFile = ./Cargo.lock;
  };
}