Files
squoosh/nix/wasm-bindgen/default.nix
2024-09-06 17:54:54 +01:00

52 lines
1.1 KiB
Nix

{
lib,
fetchCrate,
rustPlatform,
curl,
darwin,
}:
rec {
build =
{ version, sha256 }:
let
src = fetchCrate {
pname = "wasm-bindgen-cli";
inherit version sha256;
};
cargoLock = {
lockFile = "${src}/Cargo.lock";
};
in
rustPlatform.buildRustPackage {
name = "wasm-bindgen-cli";
inherit src cargoLock;
buildInputs = [
curl
darwin.apple_sdk.frameworks.Security
];
doCheck = false;
};
buildFromCargoLock =
{ cargoLock, sha256 }:
assert (cargoLock.lockFile or null == null) != (cargoLock.lockFileContents or null == null);
let
lockFileContents =
if cargoLock.lockFile != null then
builtins.readFile cargoLock.lockFile
else
cargoLock.lockFileContents;
parsedLockFile = builtins.fromTOML lockFileContents;
wasm-bindgen-version =
(lib.lists.findFirst (x: x.name == "wasm-bindgen") null parsedLockFile.package).version;
in
assert wasm-bindgen-version != null;
build {
inherit sha256;
version = wasm-bindgen-version;
};
}