This commit is contained in:
Surma
2024-08-07 01:08:01 +01:00
parent ec2a05ec33
commit 95a16e3919

View File

@@ -21,57 +21,59 @@
with pkgs; with pkgs;
rec { rec {
packages.${system} = { packages.${system} = {
default = stdenv.mkDerivation { default = stdenv.mkDerivation {
name = "mozjpeg-squoosh"; name = "mozjpeg-squoosh";
src = ./.; src = ./.;
nativeBuildInputs = [ emscripten packages.${system}.mozjpeg ]; nativeBuildInputs = [
MOZJPEG = packages.${system}.mozjpeg; emscripten
dontConfigure = true; packages.${system}.mozjpeg
buildPhase = '' ];
export HOME=$TMPDIR MOZJPEG = packages.${system}.mozjpeg;
emmake make -j$(nproc) dontConfigure = true;
''; buildPhase = ''
installPhase = '' export HOME=$TMPDIR
mkdir -p $out emmake make -j$(nproc)
cp enc/*.{wasm,js} $out '';
''; installPhase = ''
}; mkdir -p $out
mozjpeg = stdenv.mkDerivation { cp enc/*.{wasm,js} $out
name = "mozjpeg"; '';
src = mozjpeg; };
nativeBuildInputs = [ mozjpeg = stdenv.mkDerivation {
autoconf name = "mozjpeg";
automake src = mozjpeg;
libtool nativeBuildInputs = [
emscripten autoconf
pkg-config automake
]; libtool
configurePhase = '' emscripten
# $HOME is required for Emscripten to work. pkg-config
# See: https://nixos.org/manual/nixpkgs/stable/#emscripten ];
export HOME=$TMPDIR configurePhase = ''
autoreconf -ifv # $HOME is required for Emscripten to work.
emconfigure ./configure \ # See: https://nixos.org/manual/nixpkgs/stable/#emscripten
--disable-shared \ export HOME=$TMPDIR
--without-turbojpeg \ autoreconf -ifv
--without-simd \ emconfigure ./configure \
--without-arith-enc \ --disable-shared \
--without-arith-dec \ --without-turbojpeg \
--with-build-date=squoosh \ --without-simd \
--prefix=$out --without-arith-enc \
''; --without-arith-dec \
buildPhase = '' --with-build-date=squoosh \
export HOME=$TMPDIR --prefix=$out
emmake make V=1 -j$(nproc) --trace '';
''; buildPhase = ''
installPhase = '' export HOME=$TMPDIR
make install emmake make V=1 -j$(nproc) --trace
cp *.h $out/include '';
cp rdswitch.o $out/lib installPhase = ''
''; make install
dontFixup = true; cp *.h $out/include
cp rdswitch.o $out/lib
}; '';
dontFixup = true;
};
}; };
devShells.${system}.default = pkgs.mkShell { devShells.${system}.default = pkgs.mkShell {
packages = [ packages = [