-
Notifications
You must be signed in to change notification settings - Fork 3
/
flake.nix
70 lines (55 loc) · 1.95 KB
/
flake.nix
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
{
description = "A very basic flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs";
utils.url = "github:numtide/flake-utils";
rust-overlay.url = "github:oxalica/rust-overlay";
};
outputs = { self, nixpkgs, utils, rust-overlay }:
utils.lib.eachDefaultSystem (system:
let
buildTarget = "wasm32-unknown-unknown";
pkgs = import nixpkgs {
inherit system;
overlays = [ rust-overlay.overlays.default ];
};
rustToolchain = pkgs.rust-bin.stable.latest.default.override {
targets = [ buildTarget ];
};
rustPlatform = pkgs.makeRustPlatform {
cargo = rustToolchain;
rustc = rustToolchain;
};
in rec {
# Build the wasm file for the online editor
packages.wavedrom-wasm = rustPlatform.buildRustPackage rec {
name = "wavedrom-wasm";
src = ./.;
cargoLock.lockFile = ./Cargo.lock;
buildPhase = ''
cargo build --release -p ${name} --target=${buildTarget}
'';
installPhase = ''
mkdir -p $out/lib
cp target/${buildTarget}/release/*.wasm $out/lib/
'';
doCheck = false;
};
# Build the all the files for the online editor
packages.editor = pkgs.stdenv.mkDerivation {
pname = "wavedrom-rs-editor";
version = "0.1.0";
src = ./.;
buildPhase = ''
cd wavedrom-wasm
mkdir -p $out
${pkgs.wabt}/bin/wasm-strip -o $out/wavedrom.wasm ${packages.wavedrom-wasm}/lib/wavedrom_wasm.wasm
${pkgs.tailwindcss}/bin/tailwindcss -o $out/index.css -i index.scss --minify
${pkgs.minify}/bin/minify -o $out/index.html index.html
${pkgs.minify}/bin/minify -o $out/index.js index.js
cp -r assets $out/assets
'';
};
}
);
}