Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calibre fix darwin build #373940

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
6 changes: 3 additions & 3 deletions pkgs/applications/audio/mbrola/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

let
pname = "mbrola";
version = "3.3";
version = "3.3-unstable-2024-01-29";

meta = with lib; {
license = licenses.agpl3Plus;
Expand All @@ -25,8 +25,8 @@ let
src = fetchFromGitHub {
owner = "numediart";
repo = "MBROLA";
rev = version;
sha256 = "1w86gv6zs2cbr0731n49z8v6xxw0g8b0hzyv2iqb9mqcfh38l8zy";
rev = "bf17e9e1416a647979ac683657a536e8ca5d880e";
hash = "sha256-ZjCl1gx/6sGtpXAYO4sAh6dutjwzClQ7kZoq0WaaBlU=";
};

# required for cross compilation
Expand Down
25 changes: 25 additions & 0 deletions pkgs/by-name/ca/calibre/darwin-use-linux-layout.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
diff --git a/src/calibre/utils/ipc/launch.py b/src/calibre/utils/ipc/launch.py
index 533bc7eba5..1d1cd632a6 100644
--- a/src/calibre/utils/ipc/launch.py
+++ b/src/calibre/utils/ipc/launch.py
@@ -83,20 +83,10 @@ class Worker:

@property
def executable(self):
- if ismacos and not hasattr(sys, 'running_from_setup'):
- return os.path.join(macos_headless_bundle_path(), self.exe_name)
return exe_path(self.exe_name)

@property
def gui_executable(self):
- if ismacos and not hasattr(sys, 'running_from_setup'):
- if self.job_name == 'ebook-viewer':
- return os.path.join(macos_viewer_bundle_path(), self.exe_name)
- if self.job_name == 'ebook-edit':
- return os.path.join(macos_edit_book_bundle_path(), self.exe_name)
-
- return os.path.join(sys.executables_location, self.exe_name)
-
return self.executable

@property
17 changes: 17 additions & 0 deletions pkgs/by-name/ca/calibre/lift-build-platform-restrictions.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
diff --git a/setup/install.py b/setup/install.py
index 3691565309..cd5aa798b0 100644
--- a/setup/install.py
+++ b/setup/install.py
@@ -126,12 +126,6 @@ def consolidate_paths(self):
self.info('\tSHARE:', self.staging_sharedir)

def pre_sub_commands(self, opts):
- if not (islinux or isbsd or ishaiku):
- self.info('\nSetting up a source based development environment is only '
- 'supported on linux. On other platforms, see the User Manual'
- ' for help with setting up a development environment.')
- raise SystemExit(1)
-
if os.geteuid() == 0:
# We drop privileges for security, regaining them when installing
# files. Also ensures that any config files created as a side
66 changes: 53 additions & 13 deletions pkgs/by-name/ca/calibre/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
lib,
stdenv,
fetchurl,
apple-sdk_12,
buildEnv,
cmake,
fetchpatch,
ffmpeg,
Expand Down Expand Up @@ -33,6 +35,13 @@
unrarSupport ? false,
}:

let
sw = buildEnv {
name = "calibre-dependencies";
paths = [ hunspell libuchardet ];
extraOutputsToInstall = [ "dev" ];
};
in
stdenv.mkDerivation (finalAttrs: {
pname = "calibre";
version = "7.22.0";
Expand All @@ -54,7 +63,28 @@ stdenv.mkDerivation (finalAttrs: {
url = "https://raw.githubusercontent.com/debian-calibre/calibre/debian/${finalAttrs.version}+ds-1/debian/patches/hardening/0007-Hardening-Qt-code.patch";
hash = "sha256-9hi4T9LB7aklWASMR8hIuKBgZm2arDvORfmk9S8wgCA=";
})
] ++ lib.optional (!unrarSupport) ./dont_build_unrar_plugin.patch;

# On Darwin, use the Linux-style file layout instead of creating a macOS app
# bundle.
#
# Here are the reasons:
#
# 1. To avoid bloating the closure size with bundled dependencies
# 2. To avoid esoteric dependencies like the macOS framework build of Python
# 3. For easier packaging. It would require non-trivial amount of effort to
# try to untangle the build script for macOS app bundles from upstream's
# unique build setup. It requires a macOS VM running on top of a Linux
# environment.
#
# The build script includes a check to prevent us doing what we want because
# the two file layouts are incompatible with each other. So the following
# patches remove that restriction from the build script and also removes
# special handling for app bundles from the application code.
./lift-build-platform-restrictions.patch
./darwin-use-linux-layout.patch
] ++ lib.optionals (!unrarSupport) [
./dont_build_unrar_plugin.patch
];

prePatch = ''
sed -i "s@\[tool.sip.project\]@[tool.sip.project]\nsip-include-dirs = [\"${python3Packages.pyqt6}/${python3Packages.python.sitePackages}/PyQt6/bindings\"]@g" \
Expand Down Expand Up @@ -92,7 +122,6 @@ stdenv.mkDerivation (finalAttrs: {
podofo
poppler_utils
qt6.qtbase
qt6.qtwayland
sqlite
(python3Packages.python.withPackages (
ps:
Expand Down Expand Up @@ -131,24 +160,33 @@ stdenv.mkDerivation (finalAttrs: {
xxhash
# the following are distributed with calibre, but we use upstream instead
odfpy
] ++ lib.optionals (lib.lists.any (p: p == stdenv.hostPlatform.system) pyqt6-webengine.meta.platforms) [
# much of calibre's functionality is usable without a web
# browser, so we enable building on platforms which qtwebengine
# does not support by simply omitting qtwebengine.
pyqt6-webengine
] ++ lib.optionals unrarSupport [
unrardll
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
macfsevents
]
++
lib.optionals (lib.lists.any (p: p == stdenv.hostPlatform.system) pyqt6-webengine.meta.platforms)
[
# much of calibre's functionality is usable without a web
# browser, so we enable building on platforms which qtwebengine
# does not support by simply omitting qtwebengine.
pyqt6-webengine
]
++ lib.optional unrarSupport unrardll
))
xdg-utils
] ++ lib.optional speechSupport speechd-minimal;
] ++ lib.optionals speechSupport [
speechd-minimal
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
apple-sdk_12
];

installPhase = ''
runHook preInstall

export HOME=$TMPDIR/fakehome
'' + lib.optionalString stdenv.isDarwin ''
# some dependencies have to be placed under ~/sw on Darwin
mkdir -p ~
ln -s ${sw} ~/sw
'' + ''
export POPPLER_INC_DIR=${poppler_utils.dev}/include/poppler
export POPPLER_LIB_DIR=${poppler_utils.out}/lib
export MAGICK_INC=${imagemagick.dev}/include/ImageMagick
Expand Down Expand Up @@ -219,6 +257,9 @@ stdenv.mkDerivation (finalAttrs: {
$ETN 'test_qt' # we don't include svg or webp support
$ETN 'test_import_of_all_python_modules' # explores actual file paths, gets confused
$ETN 'test_websocket_basic' # flakey
$ETN 'test_recipe_browser_webengine' # hangs (on aarch64-darwin) but succeeds inside `nix develop …`
$ETN 'test_mem_leaks' # fails (on aarch64-darwin) but succeeds inside `nix develop …`
$ETN 'test_openssl' # checks for a default cafile under macOS that is not available
${lib.optionalString (!unrarSupport) "$ETN 'test_unrar'"}
)

Expand All @@ -240,6 +281,5 @@ stdenv.mkDerivation (finalAttrs: {
license = if unrarSupport then lib.licenses.unfreeRedistributable else lib.licenses.gpl3Plus;
maintainers = with lib.maintainers; [ pSub ];
platforms = lib.platforms.unix;
broken = stdenv.hostPlatform.isDarwin;
};
})
10 changes: 6 additions & 4 deletions pkgs/by-name/sp/speechd/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ let
in
stdenv.mkDerivation rec {
pname = "speech-dispatcher";
version = "0.11.5";
version = "0.12.0-rc4";

src = fetchurl {
url = "https://github.com/brailcom/speechd/releases/download/${version}/${pname}-${version}.tar.gz";
sha256 = "sha256-HOR1n/q7rxrrQzpewHOb4Gdum9+66URKezvhsq8+wSs=";
sha256 = "sha256-OXie09kZhad2Wno+gucMm6Rfkix8Y+aTQqHc+pIlQm0=";
};

patches =
Expand Down Expand Up @@ -77,9 +77,11 @@ stdenv.mkDerivation rec {
libsndfile
libao
libpulseaudio
alsa-lib
python
]
++ lib.optionals withAlsa [
alsa-lib
]
++ lib.optionals withEspeak [
espeak
sonic
Expand Down Expand Up @@ -146,7 +148,7 @@ stdenv.mkDerivation rec {
berce
jtojnar
];
platforms = platforms.linux;
platforms = platforms.unix;
mainProgram = "speech-dispatcher";
};
}
21 changes: 21 additions & 0 deletions pkgs/by-name/sv/svox/fix-darwin-endian-h-include.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
diff --git a/pico/lib/picopltf.h b/pico/lib/picopltf.h
index e206b6a..8af8663 100644
--- a/pico/lib/picopltf.h
+++ b/pico/lib/picopltf.h
@@ -66,7 +66,16 @@
#define PICO_PLATFORM_STRING "UnknownPlatform"
#endif

+#if defined(__FreeBSD__)
+#define __BYTE_ORDER _BYTE_ORDER
+#define __BIG_ENDIAN _BIG_ENDIAN
+#include <sys/endian.h>
+#elif (PICO_PLATFORM == PICO_MacOSX)
+#include <machine/endian.h>
+#else
#include <endian.h>
+#endif
+
#if __BYTE_ORDER == __BIG_ENDIAN
#define PICO_ENDIANNESS ENDIANNESS_BIG
#else
4 changes: 3 additions & 1 deletion pkgs/by-name/sv/svox/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ stdenv.mkDerivation {
sha256 = "0k3m7vh1ak9gmxd83x29cvhzfkybgz5hnlhd9xj19l1bjyx84s8v";
};

patches = [ ./fix-darwin-endian-h-include.patch ];

postPatch = ''
cd pico
'';
Expand All @@ -29,7 +31,7 @@ stdenv.mkDerivation {
meta = with lib; {
description = "Text-to-speech engine";
homepage = "https://android.googlesource.com/platform/external/svox";
platforms = platforms.linux;
platforms = platforms.unix;
license = licenses.asl20;
maintainers = with maintainers; [ abbradar ];
mainProgram = "pico2wave";
Expand Down
133 changes: 133 additions & 0 deletions pkgs/development/cuda-modules/cudnn-frontend/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
cmake_minimum_required(VERSION 3.23)

project(cudnn_frontend VERSION 1.8.0)

option(CUDNN_FRONTEND_SKIP_JSON_LIB "Defines whether FE should not include nlohmann/json.hpp." OFF)
option(CUDNN_FRONTEND_BUILD_SAMPLES "Defines if samples are built or not." ON)
option(CUDNN_FRONTEND_BUILD_TESTS "Defines if unittests are built or not." ON)
option(CUDNN_FRONTEND_BUILD_PYTHON_BINDINGS "Defines if python bindings are built or not." OFF)

if(MSVC OR MSYS OR MINGW)
add_compile_options(/W4 /WX)
else()
add_compile_options(-Wall -Wextra -Wpedantic -Werror -Wno-error=attributes -Wno-attributes -Wno-error=unused-function -Wno-unused-function)
endif()

add_library(cudnn_frontend INTERFACE)

# Add header files to library
file(GLOB_RECURSE CUDNN_FRONTEND_INCLUDE_FILES "include/*")
target_sources(
cudnn_frontend
PUBLIC
FILE_SET
HEADERS
BASE_DIRS
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
FILES
"${CUDNN_FRONTEND_INCLUDE_FILES}"
)
unset(CUDNN_FRONTEND_INCLUDE_FILES)

target_compile_definitions(cudnn_frontend INTERFACE $<$<BOOL:${CUDNN_FRONTEND_SKIP_JSON_LIB}>:CUDNN_FRONTEND_SKIP_JSON_LIB>)

target_include_directories(
cudnn_frontend
INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
)

# Find the cuda compiler
find_package(CUDAToolkit REQUIRED)

target_include_directories(cudnn_frontend INTERFACE ${CUDAToolkit_INCLUDE_DIRS})

target_compile_features(cudnn_frontend INTERFACE cxx_std_17)

# Make PCH for targets to link against
add_library(_cudnn_frontend_pch INTERFACE)
target_precompile_headers(_cudnn_frontend_pch INTERFACE ${PROJECT_SOURCE_DIR}/include/cudnn_frontend.h)

if (CUDNN_FRONTEND_BUILD_SAMPLES)
add_subdirectory(samples)
target_link_libraries(
samples
PRIVATE
CUDA::cublasLt
CUDA::nvrtc
)
target_link_libraries(
legacy_samples
PRIVATE
CUDA::cublasLt
CUDA::nvrtc
)
endif()

if (CUDNN_FRONTEND_BUILD_TESTS)
add_subdirectory(test)
target_link_libraries(
tests
CUDA::cublasLt
CUDA::nvrtc
)
endif()

if (CUDNN_FRONTEND_BUILD_PYTHON_BINDINGS)
add_subdirectory(python)
endif()

# Introduce variables:
# * CMAKE_INSTALL_LIBDIR
# * CMAKE_INSTALL_BINDIR
# * CMAKE_INSTALL_INCLUDEDIR
include(GNUInstallDirs)

# Install and export the header files
install(
TARGETS
cudnn_frontend
EXPORT
cudnn_frontend_targets
FILE_SET HEADERS
)

if (CUDNN_FRONTEND_BUILD_SAMPLES)
install(TARGETS legacy_samples samples RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()

if (CUDNN_FRONTEND_BUILD_TESTS)
install(TARGETS tests RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()

# See https://cmake.org/cmake/help/latest/module/CMakePackageConfigHelpers.html#example-generating-package-files
include(CMakePackageConfigHelpers)

export(
EXPORT
cudnn_frontend_targets
FILE
"${CMAKE_CURRENT_BINARY_DIR}/cudnn_frontend/cudnn_frontend-targets.cmake"
)
install(
EXPORT
cudnn_frontend_targets
FILE
cudnn_frontend-targets.cmake
DESTINATION
"${CMAKE_INSTALL_LIBDIR}/cmake/cudnn_frontend"
)

configure_package_config_file(
cudnn_frontend-config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/cudnn_frontend-config.cmake"
INSTALL_DESTINATION
"${CMAKE_INSTALL_LIBDIR}/cmake/cudnn_frontend"
)
install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/cudnn_frontend-config.cmake"
DESTINATION
"${CMAKE_INSTALL_LIBDIR}/cmake/cudnn_frontend"
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@PACKAGE_INIT@

include(${CMAKE_CURRENT_LIST_DIR}/cudnn_frontend-targets.cmake)
Loading
Loading