summaryrefslogtreecommitdiff
path: root/flake.nix
blob: 5bff2cc75debba3b43eb1eb49a4bbac1f85b32b0 (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
{
  inputs = {
    rust-overlay.url = "github:oxalica/rust-overlay";
  };
  outputs = {
    self,
    nixpkgs,
    rust-overlay,
  }: let
    overlays = [(import rust-overlay)];
    system = "x86_64-linux";
    pkgs = import nixpkgs {
      inherit system overlays;
    };
    asmjs-rust-bin = pkgs.rust-bin.stable.latest.default.override {
      targets = ["asmjs-unknown-emscripten"];
    };
    rustPlatform = pkgs.makeRustPlatform {
      cargo = asmjs-rust-bin;
      rustc = asmjs-rust-bin;
    };
  in {
    packages.x86_64-linux.default = rustPlatform.buildRustPackage rec {
      name = "web";
      src = ./.;
      cargoLock = {
        lockFile = ./Cargo.lock;
      };
      doCheck = false;
      HOME = "$TMPDIR";
      buildPhase = ''
        cargo build --target asmjs-unknown-emscripten --release
      '';
      nativeBuildInputs = [pkgs.SDL2 pkgs.SDL2_gfx pkgs.emscripten];
      RUST_BACKTRACE = "full";
      buildInputs = [pkgs.python3Packages.requests];
    };
  };
}