Skip to content

Commit

Permalink
Update resize codec build
Browse files Browse the repository at this point in the history
  • Loading branch information
surma committed Sep 6, 2024
1 parent 738d07d commit 4f93abb
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 156 deletions.
140 changes: 14 additions & 126 deletions codecs/resize/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 11 additions & 19 deletions codecs/resize/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,37 @@
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/24.05";
flake-utils.url = "github:numtide/flake-utils";
wasm-bindgen = {
url = "path:../../nix/wasm-bindgen";
inputs.nixpkgs.follows = "nixpkgs";
};
rust-helpers = {
url = "path:../../nix/rust-helpers";
inputs.nixpkgs.follows = "nixpkgs";
};
squoosh-codec-builders = {
url = "path:../../nix/squoosh-codec-builders";
inputs.nixpkgs.follows = "nixpkgs";
inputs.rust-helpers.follows = "rust-helpers";
inputs.wasm-bindgen.follows = "wasm-bindgen";
};
fenix.url = "github:nix-community/fenix/7bad6c7ff73b784a9c7de9147626c8d5d5072809";
};
outputs =
{
self,
nixpkgs,
flake-utils,
squoosh-codec-builders,
...
fenix,
}:
flake-utils.lib.eachDefaultSystem (
system:
with nixpkgs.legacyPackages.${system};
let
pkgs = nixpkgs.legacyPackages.${system};
inherit (pkgs) callPackage writeShellScriptBin;

squooshCodecBuilders = callPackage (import ../../nix/squoosh-codec-builders) {fenix = fenix.packages.${system};};

src = ./.;
in
{
packages = rec {
default = resize-squoosh;
resize-squoosh = squoosh-codec-builders.lib.buildSquooshCodecRust {
resize-squoosh = squooshCodecBuilders.buildSquooshCodecRust {
name = "resize-squoosh";
inherit system src;
cargoLock = {
lockFile = "${src}/Cargo.lock";
};
wasmBindgenSha = "sha256-HTElSB76gqCpDu8S0ZJlfd/S4ftMrbwxFgJM9OXBRz8=";
wasmBindgen = {
sha256 = "sha256-HTElSB76gqCpDu8S0ZJlfd/S4ftMrbwxFgJM9OXBRz8=";
};
};

installScript = writeShellScriptBin "install.sh" ''
Expand Down
Binary file modified codecs/resize/wasm_build/squoosh_resize_bg.wasm
Binary file not shown.
18 changes: 13 additions & 5 deletions nix/squoosh-codec-builders/default.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
{
pkgs,
fenix,
wasm-bindgen,
rust-helpers,
wasm-bindgen ? pkgs.callPackage (import ../wasm-bindgen) { },
rust-helpers ? pkgs.callPackage (import ../rust-helpers) { inherit fenix; },
stdenv,
}:
let
inherit (rust-helpers) buildRustPackage;
in

{
buildSquooshCodecRust =
{
Expand All @@ -18,20 +23,23 @@
...
}@args:
let
codecBuild = rust-helpers.lib.buildRustPackage {
codecBuild = buildRustPackage {
inherit src cargoLock;
name = "${name}-codec";
target = "wasm32-unknown-unknown";
};

wasm-bindgen-bin = wasm-bindgen.lib.buildFromCargoLock {
wasm-bindgen-bin = wasm-bindgen.buildFromCargoLock {
inherit cargoLock;
sha256 = wasmBindgen.sha256;
};
in
if wasmBindgen != null then
stdenv.mkDerivation (
(removeAttrs args [ "cargoLock" ])
(removeAttrs args [
"cargoLock"
"wasmBindgen"
])
// {
inherit codecBuild;
dontConfigure = true;
Expand Down
8 changes: 2 additions & 6 deletions nix/wasm-bindgen/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@ rec {
};

buildFromCargoLock =
{
system,
cargoLock,
sha256,
}:
{ cargoLock, sha256 }:
assert (cargoLock.lockFile or null == null) != (cargoLock.lockFileContents or null == null);
let
lockFileContents =
Expand All @@ -49,7 +45,7 @@ rec {
in
assert wasm-bindgen-version != null;
build {
inherit system sha256;
inherit sha256;
version = wasm-bindgen-version;
};
}

0 comments on commit 4f93abb

Please sign in to comment.