overlay/plume: properly wasm-pack

This commit is contained in:
Astro 2021-12-23 22:26:05 +01:00
parent af6535fd21
commit b8abf0e53d
1 changed files with 30 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{ naersk, fenix
, system, stdenv, fetchFromGitHub, buildEnv
, pkg-config, gettext
, pkg-config, gettext, wasm-pack, wasm-bindgen-cli
, openssl, postgresql
}:
@ -60,6 +60,14 @@ let
openssl
postgresql
];
overrideMain = oa: {
installPhase = ''
${oa.installPhase}
mkdir -p $out/share/plume
cp -ar static $out/share/plume/
'';
};
};
plm = naersk-lib.buildPackage {
@ -80,7 +88,7 @@ let
pname = "plume-front";
root = src;
nativeBuildInputs = [
gettext
gettext wasm-pack wasm-bindgen-cli
];
CARGO_BUILD_TARGET = "wasm32-unknown-unknown";
cargoBuildOptions = x:
@ -88,6 +96,26 @@ let
"--package=plume-front"
];
copyLibs = true;
overrideMain = oa: {
buildPhase = ''
substituteInPlace plume-front/Cargo.toml \
--replace '"cdylib"' '"cdylib", "rlib"'
cat >>plume-front/Cargo.toml <<EOF
[package.metadata.wasm-pack.profile.release]
# wasm-opt is missing from nixpkgs
wasm-opt = false
EOF
wasm-pack build --target web --release plume-front
'';
installPhase = ''
${oa.installPhase}
mkdir -p $out/share/plume/static
cp -a plume-front/pkg/*.{js,ts,wasm} $out/share/plume/static/
'';
};
};
in buildEnv {
name = "plume-env";