Work on all systems

This commit is contained in:
Surma
2024-08-07 10:34:05 +01:00
parent 95a16e3919
commit 2bd1eeceb8
2 changed files with 108 additions and 72 deletions

View File

@@ -1,6 +1,24 @@
{ {
"nodes": { "nodes": {
"mozjpeg": { "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"
}
},
"mozjpeg-src": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1499684294, "lastModified": 1499684294,
@@ -35,9 +53,25 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"mozjpeg": "mozjpeg", "flake-utils": "flake-utils",
"mozjpeg-src": "mozjpeg-src",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
} }
},
"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", "root": "root",

View File

@@ -1,9 +1,8 @@
{ {
inputs = { inputs = {
nixpkgs = { nixpkgs.url = "github:nixos/nixpkgs/24.05";
url = "github:nixos/nixpkgs/24.05"; flake-utils.url = "github:numtide/flake-utils";
}; mozjpeg-src = {
mozjpeg = {
url = "github:mozilla/mozjpeg/v3.3.1"; url = "github:mozilla/mozjpeg/v3.3.1";
flake = false; flake = false;
}; };
@@ -12,80 +11,83 @@
{ {
self, self,
nixpkgs, nixpkgs,
mozjpeg, flake-utils,
mozjpeg-src,
}: }:
let flake-utils.lib.eachDefaultSystem (
system = "aarch64-darwin"; system:
pkgs = import nixpkgs { inherit system; }; let
in pkgs = nixpkgs.legacyPackages.${system};
with pkgs; in
rec { with pkgs;
packages.${system} = { {
default = stdenv.mkDerivation { packages = rec {
name = "mozjpeg-squoosh"; default = stdenv.mkDerivation {
src = ./.; name = "mozjpeg-squoosh";
nativeBuildInputs = [ src = ./.;
emscripten nativeBuildInputs = [
packages.${system}.mozjpeg emscripten
]; mozjpeg
MOZJPEG = packages.${system}.mozjpeg; ];
dontConfigure = true; MOZJPEG = mozjpeg;
buildPhase = '' dontConfigure = true;
export HOME=$TMPDIR buildPhase = ''
emmake make -j$(nproc) export HOME=$TMPDIR
''; emmake make -j$(nproc)
installPhase = '' '';
mkdir -p $out installPhase = ''
cp enc/*.{wasm,js} $out mkdir -p $out
''; cp enc/*.{wasm,js} $out
'';
};
mozjpeg = stdenv.mkDerivation {
name = "mozjpeg";
src = mozjpeg-src;
nativeBuildInputs = [
autoconf
automake
libtool
emscripten
pkg-config
];
configurePhase = ''
# $HOME is required for Emscripten to work.
# See: https://nixos.org/manual/nixpkgs/stable/#emscripten
export HOME=$TMPDIR
autoreconf -ifv
emconfigure ./configure \
--disable-shared \
--without-turbojpeg \
--without-simd \
--without-arith-enc \
--without-arith-dec \
--with-build-date=squoosh \
--prefix=$out
'';
buildPhase = ''
export HOME=$TMPDIR
emmake make V=1 -j$(nproc) --trace
'';
installPhase = ''
make install
cp *.h $out/include
cp rdswitch.o $out/lib
'';
dontFixup = true;
};
}; };
mozjpeg = stdenv.mkDerivation { devShells.default = pkgs.mkShell {
name = "mozjpeg"; packages = [
src = mozjpeg;
nativeBuildInputs = [
autoconf autoconf
automake automake
libtool libtool
emscripten emscripten
pkg-config pkg-config
]; ];
configurePhase = '' shellHook = ''
# $HOME is required for Emscripten to work. echo "Path to MozJPEG: ${mozjpeg-src}"
# See: https://nixos.org/manual/nixpkgs/stable/#emscripten
export HOME=$TMPDIR
autoreconf -ifv
emconfigure ./configure \
--disable-shared \
--without-turbojpeg \
--without-simd \
--without-arith-enc \
--without-arith-dec \
--with-build-date=squoosh \
--prefix=$out
''; '';
buildPhase = ''
export HOME=$TMPDIR
emmake make V=1 -j$(nproc) --trace
'';
installPhase = ''
make install
cp *.h $out/include
cp rdswitch.o $out/lib
'';
dontFixup = true;
}; };
}; }
devShells.${system}.default = pkgs.mkShell { );
packages = [
autoconf
automake
libtool
emscripten
pkg-config
];
shellHook = ''
echo "Path to MozJPEG: ${mozjpeg}"
'';
};
};
} }