mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-12 08:47:31 +00:00
Port rotate codec to nix
This commit is contained in:
@@ -18,15 +18,16 @@
|
|||||||
inherit (pkgs) callPackage writeShellScriptBin;
|
inherit (pkgs) callPackage writeShellScriptBin;
|
||||||
|
|
||||||
squooshCodecBuilders = callPackage (import ../../nix/squoosh-codec-builders) {fenix = fenix.packages.${system};};
|
squooshCodecBuilders = callPackage (import ../../nix/squoosh-codec-builders) {fenix = fenix.packages.${system};};
|
||||||
|
inherit (squooshCodecBuilders) buildSquooshCodecRust;
|
||||||
|
|
||||||
src = ./.;
|
src = ./.;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
packages = rec {
|
packages = rec {
|
||||||
default = resize-squoosh;
|
default = resize-squoosh;
|
||||||
resize-squoosh = squooshCodecBuilders.buildSquooshCodecRust {
|
resize-squoosh = buildSquooshCodecRust {
|
||||||
name = "resize-squoosh";
|
name = "resize-squoosh";
|
||||||
inherit system src;
|
inherit src;
|
||||||
cargoLock = {
|
cargoLock = {
|
||||||
lockFile = "${src}/Cargo.lock";
|
lockFile = "${src}/Cargo.lock";
|
||||||
};
|
};
|
||||||
|
|||||||
115
codecs/rotate/flake.lock
generated
Normal file
115
codecs/rotate/flake.lock
generated
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"fenix": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": "nixpkgs",
|
||||||
|
"rust-analyzer-src": "rust-analyzer-src"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1723616992,
|
||||||
|
"narHash": "sha256-jDHYfEECzFwZm4huz7AbPjlH3jJ4/2ns9PddtFA5XMY=",
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "fenix",
|
||||||
|
"rev": "7bad6c7ff73b784a9c7de9147626c8d5d5072809",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "fenix",
|
||||||
|
"rev": "7bad6c7ff73b784a9c7de9147626c8d5d5072809",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"flake-utils": {
|
||||||
|
"inputs": {
|
||||||
|
"systems": "systems"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1710146030,
|
||||||
|
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1723362943,
|
||||||
|
"narHash": "sha256-dFZRVSgmJkyM0bkPpaYRtG/kRMRTorUIDj8BxoOt1T4=",
|
||||||
|
"owner": "nixos",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "a58bc8ad779655e790115244571758e8de055e3d",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nixos",
|
||||||
|
"ref": "nixos-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs_2": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1717179513,
|
||||||
|
"narHash": "sha256-vboIEwIQojofItm2xGCdZCzW96U85l9nDW3ifMuAIdM=",
|
||||||
|
"owner": "nixos",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "63dacb46bf939521bdc93981b4cbb7ecb58427a0",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nixos",
|
||||||
|
"ref": "24.05",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"fenix": "fenix",
|
||||||
|
"flake-utils": "flake-utils",
|
||||||
|
"nixpkgs": "nixpkgs_2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"rust-analyzer-src": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1723561310,
|
||||||
|
"narHash": "sha256-a3KMMsIDvdo+ClLabh5wfJoa17YTSvy2wDLb8yZCXvc=",
|
||||||
|
"owner": "rust-lang",
|
||||||
|
"repo": "rust-analyzer",
|
||||||
|
"rev": "78c2bdce860dbd996a8083224d01a96660dd6a15",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "rust-lang",
|
||||||
|
"ref": "nightly",
|
||||||
|
"repo": "rust-analyzer",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"systems": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1681028828,
|
||||||
|
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
||||||
51
codecs/rotate/flake.nix
Normal file
51
codecs/rotate/flake.nix
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
|
||||||
|
{
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:nixos/nixpkgs/24.05";
|
||||||
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
|
fenix.url = "github:nix-community/fenix/7bad6c7ff73b784a9c7de9147626c8d5d5072809";
|
||||||
|
};
|
||||||
|
outputs =
|
||||||
|
{
|
||||||
|
self,
|
||||||
|
nixpkgs,
|
||||||
|
flake-utils,
|
||||||
|
fenix
|
||||||
|
}:
|
||||||
|
flake-utils.lib.eachDefaultSystem (
|
||||||
|
system:
|
||||||
|
let
|
||||||
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
|
inherit (pkgs) callPackage writeShellScriptBin;
|
||||||
|
|
||||||
|
squooshCodecBuilders = callPackage (import ../../nix/squoosh-codec-builders) {fenix = fenix.packages.${system};};
|
||||||
|
inherit (squooshCodecBuilders) buildSquooshCodecRust;
|
||||||
|
|
||||||
|
src = ./.;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
packages = rec {
|
||||||
|
default = rotate-squoosh;
|
||||||
|
rotate-squoosh = buildSquooshCodecRust {
|
||||||
|
name = "rotate-squoosh";
|
||||||
|
inherit src;
|
||||||
|
cargoLock = {
|
||||||
|
lockFile = "${src}/Cargo.lock";
|
||||||
|
};
|
||||||
|
wasmBindgen = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
installScript = writeShellScriptBin "install.sh" ''
|
||||||
|
${pkgs.coreutils}/bin/mkdir -p wasm_build
|
||||||
|
${pkgs.rsync}/bin/rsync --chmod=u+w -r ${self.packages.${system}.rotate-squoosh}/* wasm_build/
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
apps = {
|
||||||
|
install = {
|
||||||
|
type = "app";
|
||||||
|
program = "${self.packages.${system}.installScript}/bin/install.sh";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
Binary file not shown.
BIN
codecs/rotate/wasm_build/optimized.wasm
Normal file
BIN
codecs/rotate/wasm_build/optimized.wasm
Normal file
Binary file not shown.
@@ -3,6 +3,7 @@
|
|||||||
fenix,
|
fenix,
|
||||||
wasm-bindgen ? pkgs.callPackage (import ../wasm-bindgen) { },
|
wasm-bindgen ? pkgs.callPackage (import ../wasm-bindgen) { },
|
||||||
rust-helpers ? pkgs.callPackage (import ../rust-helpers) { inherit fenix; },
|
rust-helpers ? pkgs.callPackage (import ../rust-helpers) { inherit fenix; },
|
||||||
|
binaryen,
|
||||||
stdenv,
|
stdenv,
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
@@ -43,7 +44,7 @@ in
|
|||||||
// {
|
// {
|
||||||
inherit codecBuild;
|
inherit codecBuild;
|
||||||
dontConfigure = true;
|
dontConfigure = true;
|
||||||
nativeBuildInputs = (args.nativeBuildInputs or [ ]) ++ [ wasm-bindgen-bin ];
|
nativeBuildInputs = [ wasm-bindgen-bin ];
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
runHook preBuild
|
runHook preBuild
|
||||||
|
|
||||||
@@ -55,5 +56,27 @@ in
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
codecBuild;
|
stdenv.mkDerivation (
|
||||||
|
(removeAttrs args [
|
||||||
|
"cargoLock"
|
||||||
|
"wasmBindgen"
|
||||||
|
])
|
||||||
|
// {
|
||||||
|
inherit codecBuild;
|
||||||
|
dontConfigure = true;
|
||||||
|
nativeBuildInputs = [ binaryen ];
|
||||||
|
buildPhase = ''
|
||||||
|
runHook preBuild
|
||||||
|
|
||||||
|
wasm-opt -O3 --strip -o optimized.wasm $codecBuild/*.wasm
|
||||||
|
|
||||||
|
runHook postBuild
|
||||||
|
'';
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out
|
||||||
|
cp optimized.wasm $out
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
import wasmUrl from 'url:codecs/rotate/rotate.wasm';
|
import wasmUrl from 'url:codecs/rotate/wasm_build/optimized.wasm';
|
||||||
import { Options } from '../shared/meta';
|
import { Options } from '../shared/meta';
|
||||||
|
|
||||||
export interface RotateModuleInstance {
|
export interface RotateModuleInstance {
|
||||||
|
|||||||
Reference in New Issue
Block a user