mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-19 12:08:57 +00:00
WIP
This commit is contained in:
66
nix/squoosh-codec-builders/flake.nix
Normal file
66
nix/squoosh-codec-builders/flake.nix
Normal file
@@ -0,0 +1,66 @@
|
||||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/24.05";
|
||||
fenix.url = "github:nix-community/fenix";
|
||||
wasm-bindgen = {
|
||||
url = "../wasm-bindgen";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
rust-helpers = {
|
||||
url = "../rust-helpers";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
outputs =
|
||||
{
|
||||
self,
|
||||
nixpkgs,
|
||||
fenix,
|
||||
wasm-bindgen,
|
||||
rust-helpers,
|
||||
}:
|
||||
{
|
||||
lib = {
|
||||
buildSquooshCodecRust =
|
||||
{
|
||||
name,
|
||||
system,
|
||||
src,
|
||||
cargoLock ? {
|
||||
lockFile = "${src}/Cargo.lock";
|
||||
},
|
||||
wasmBindgenSha,
|
||||
...
|
||||
}@args:
|
||||
with nixpkgs.legacyPackages.${system};
|
||||
let
|
||||
wasm-bindgen-bin = wasm-bindgen.lib.buildFromCargoLock {
|
||||
inherit system cargoLock;
|
||||
sha256 = wasmBindgenSha;
|
||||
};
|
||||
|
||||
codecBuild = rust-helpers.lib.buildRustPackage {
|
||||
inherit system src cargoLock;
|
||||
name = "${name}-codec";
|
||||
target = "wasm32-unknown-unknown";
|
||||
};
|
||||
in
|
||||
stdenv.mkDerivation (
|
||||
(removeAttrs args [ "cargoLock" ])
|
||||
// {
|
||||
inherit codecBuild;
|
||||
dontConfigure = true;
|
||||
nativeBuildInputs = (args.nativeBuildInputs or [ ]) ++ [ wasm-bindgen-bin ];
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
wasm-bindgen --target web --out-dir $out $codecBuild/*.wasm
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
dontInstall = true;
|
||||
}
|
||||
);
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user