This commit is contained in:
Andrew Haynes
2026-03-26 11:27:46 -04:00
parent babb721f15
commit e2436b57ac
+13 -7
View File
@@ -8,25 +8,31 @@
system = "aarch64-darwin"; system = "aarch64-darwin";
pkgs = nixpkgs.legacyPackages.${system}; pkgs = nixpkgs.legacyPackages.${system};
in { in {
# This builds the 'PROCESSOR' library so other projects can find it
packages.${system}.default = pkgs.stdenv.mkDerivation { packages.${system}.default = pkgs.stdenv.mkDerivation {
name = "image_processor"; name = "image_processor";
src = ./.; src = ./.;
nativeBuildInputs = [pkgs.cmake];
# Add pkg-config here so CMake can find it during the build
nativeBuildInputs = [
pkgs.cmake
pkgs.pkg-config
];
buildInputs = [pkgs.libjpeg_turbo]; buildInputs = [pkgs.libjpeg_turbo];
# This ensures the .dylib and .h files are moved to the right place
# Nix's default CMake phase will run, but we need to ensure
# the library actually gets installed to the nix store output
installPhase = '' installPhase = ''
mkdir -p $out/lib $out/include mkdir -p $out/lib $out/include
cp libPROCESSOR.dylib $out/lib/ || cp libPROCESSOR.a $out/lib/ cp libPROCESSOR.dylib $out/lib/ 2>/dev/null || cp libPROCESSOR.a $out/lib/
cp *.h $out/include/ cp *.h $out/include/
''; '';
}; };
devShells.${system}.default = pkgs.mkShell { devShells.${system}.default = pkgs.mkShell {
# This makes sure the shell also has the tools for manual debugging
nativeBuildInputs = [pkgs.pkg-config pkgs.cmake];
buildInputs = [pkgs.libjpeg_turbo]; buildInputs = [pkgs.libjpeg_turbo];
shellHook = ''
export PKG_CONFIG_PATH="${pkgs.libjpeg_turbo.dev}/lib/pkgconfig:$PKG_CONFIG_PATH"
'';
}; };
}; };
} }