Filter sources

This commit is contained in:
Surma
2024-09-08 10:46:45 +01:00
parent 24e63eafc6
commit aa7b284e65
6 changed files with 14 additions and 18 deletions

View File

@@ -18,7 +18,7 @@
system: system:
let let
pkgs = nixpkgs.legacyPackages.${system}; pkgs = nixpkgs.legacyPackages.${system};
inherit (pkgs) callPackage stdenv; inherit (pkgs) callPackage stdenv lib;
buildSquooshCppCodec = callPackage (import ../../nix/squoosh-cxx-builder) {}; buildSquooshCppCodec = callPackage (import ../../nix/squoosh-cxx-builder) {};
mkInstallable = callPackage (import ../../nix/mk-installable) {}; mkInstallable = callPackage (import ../../nix/mk-installable) {};
@@ -30,8 +30,9 @@
default = mozjpeg-squoosh; default = mozjpeg-squoosh;
mozjpeg-squoosh = buildSquooshCppCodec { mozjpeg-squoosh = buildSquooshCppCodec {
name = "mozjpeg-squoosh"; name = "mozjpeg-squoosh";
src = ./.; src = lib.sources.sourceByRegex ./. ["Makefile" "enc(/.+)?"];
MOZJPEG = mozjpeg; MOZJPEG = mozjpeg;
dontConfigure = true; dontConfigure = true;
decoder = null; decoder = null;
}; };

View File

@@ -15,12 +15,12 @@
system: system:
let let
pkgs = nixpkgs.legacyPackages.${system}; pkgs = nixpkgs.legacyPackages.${system};
inherit (pkgs) callPackage; inherit (pkgs) callPackage lib;
buildSquooshRustCodec= callPackage (import ../../nix/squoosh-rust-builder) {fenix = fenix.packages.${system};}; buildSquooshRustCodec= callPackage (import ../../nix/squoosh-rust-builder) {fenix = fenix.packages.${system};};
mkInstallable = callPackage (import ../../nix/mk-installable) {}; mkInstallable = callPackage (import ../../nix/mk-installable) {};
src = ./.; src = lib.sources.sourceByRegex ./. ["Makefile" "enc(/.+)?"];
in in
mkInstallable { mkInstallable {
packages = rec { packages = rec {

View File

@@ -16,12 +16,12 @@
system: system:
let let
pkgs = nixpkgs.legacyPackages.${system}; pkgs = nixpkgs.legacyPackages.${system};
inherit (pkgs) callPackage; inherit (pkgs) callPackage lib;
buildSquooshRustCodec= callPackage (import ../../nix/squoosh-rust-builder) {fenix = fenix.packages.${system};}; buildSquooshRustCodec= callPackage (import ../../nix/squoosh-rust-builder) {fenix = fenix.packages.${system};};
mkInstallable = callPackage (import ../../nix/mk-installable) {}; mkInstallable = callPackage (import ../../nix/mk-installable) {};
src = ./.; src = lib.sources.sourceByRegex ./. ["Cargo\.*" ".*\.rs"];
in in
mkInstallable { mkInstallable {
packages = rec { packages = rec {

View File

@@ -28,21 +28,17 @@
system: system:
let let
pkgs = nixpkgs.legacyPackages.${system}; pkgs = nixpkgs.legacyPackages.${system};
inherit (pkgs) lib stdenv runCommand emscripten writeShellScriptBin cmake; inherit (pkgs) lib stdenv runCommand emscripten writeShellScriptBin cmake callPackage;
buildSquooshCppCodec = callPackage (import ../../nix/squoosh-cxx-builder) {};
mkInstallable = callPackage (import ../../nix/mk-installable) {};
packageVariantBuilder = packageVariantBuilder =
name: name:
{ simd }@variantOptions: { simd }@variantOptions:
{ {
"webp-squoosh-${name}" = stdenv.mkDerivation { "webp-squoosh-${name}" = buildSquooshCppCodec {
name = "webp-squoosh-${name}"; name = "webp-squoosh-${name}";
# Only copy files that are actually relevant to avoid unnecessary src = lib.sources.sourceByRegex ./. ["Makefile" "enc(/.+)?" "dec(/.+)?"];
# cache invalidations.
src = runCommand "src" { } ''
mkdir $out
cp -r ${./.}/enc $out/
cp -r ${./.}/dec $out/
cp ${./.}/Makefile $out/
'';
nativeBuildInputs = [ nativeBuildInputs = [
emscripten emscripten
self.packages.${system}."webp-${name}" self.packages.${system}."webp-${name}"

View File

@@ -5,7 +5,6 @@
}: }:
{ {
name, name,
src,
nativeBuildInputs ? [ ], nativeBuildInputs ? [ ],
encoder ? "enc", encoder ? "enc",
decoder ? "dec", decoder ? "dec",
@@ -16,7 +15,7 @@ stdenv.mkDerivation (
final: final:
args args
// { // {
inherit name src; inherit name;
nativeBuildInputs = [ pkgs.emscripten ] ++ nativeBuildInputs; nativeBuildInputs = [ pkgs.emscripten ] ++ nativeBuildInputs;
buildPhase = '' buildPhase = ''
export HOME=$TMPDIR export HOME=$TMPDIR