From 7ae67c6fa2811783f214bb9227d791e5fc3e362c Mon Sep 17 00:00:00 2001 From: Malte Poll <1780588+malt3@users.noreply.github.com> Date: Tue, 14 May 2024 21:17:21 +0200 Subject: [PATCH] espanso: update darwin patches This commit also removes patches that seem no longer necessary, removes `--replace` calls that were not working, and uses `--replace-fail` going forward in keeping with the deprecation of `--replace`. Co-authored-by: Nathan Henrie --- pkgs/applications/office/espanso/default.nix | 24 +- .../office/espanso/inject-wx-on-darwin.patch | 223 ------------------ pkgs/top-level/all-packages.nix | 2 +- 3 files changed, 14 insertions(+), 235 deletions(-) delete mode 100644 pkgs/applications/office/espanso/inject-wx-on-darwin.patch diff --git a/pkgs/applications/office/espanso/default.nix b/pkgs/applications/office/espanso/default.nix index b9e00a5ec313..14a4e6a25ffc 100644 --- a/pkgs/applications/office/espanso/default.nix +++ b/pkgs/applications/office/espanso/default.nix @@ -28,6 +28,7 @@ , QTKit , AVKit , WebKit +, System , waylandSupport ? false , x11Support ? stdenv.isLinux , testers @@ -55,10 +56,6 @@ rustPlatform.buildRustPackage rec { }; }; - cargoPatches = lib.optionals stdenv.isDarwin [ - ./inject-wx-on-darwin.patch - ]; - nativeBuildInputs = [ extra-cmake-modules pkg-config @@ -96,6 +93,7 @@ rustPlatform.buildRustPackage rec { QTKit AVKit WebKit + System ] ++ lib.optionals waylandSupport [ wl-clipboard ] ++ lib.optionals x11Support [ @@ -108,16 +106,13 @@ rustPlatform.buildRustPackage rec { postPatch = lib.optionalString stdenv.isDarwin '' substituteInPlace scripts/create_bundle.sh \ - --replace target/mac/ $out/Applications/ \ - --replace /bin/echo ${coreutils}/bin/echo + --replace-fail target/mac/ $out/Applications/ \ + --replace-fail /bin/echo ${coreutils}/bin/echo patchShebangs scripts/create_bundle.sh substituteInPlace espanso/src/res/macos/Info.plist \ - --replace "espanso" "${placeholder "out"}/Applications/Espanso.app/Contents/MacOS/espanso" - substituteInPlace espanso/src/res/macos/com.federicoterzi.espanso.plist \ - --replace "/Applications/Espanso.app/Contents/MacOS/espanso" "${placeholder "out"}/Applications/Espanso.app/Contents/MacOS/espanso" \ - --replace "/usr/bin" "${placeholder "out"}/bin:/usr/bin" + --replace-fail "espanso" "${placeholder "out"}/Applications/Espanso.app/Contents/MacOS/espanso" substituteInPlace espanso/src/path/macos.rs espanso/src/path/linux.rs \ - --replace '"/usr/local/bin/espanso"' '"${placeholder "out"}/bin/espanso"' + --replace-fail '"/usr/local/bin/espanso"' '"${placeholder "out"}/bin/espanso"' ''; # Some tests require networking @@ -153,6 +148,13 @@ rustPlatform.buildRustPackage rec { license = licenses.gpl3Plus; maintainers = with maintainers; [ kimat pyrox0 ]; platforms = platforms.unix; + # With apple_sdk_10_12, + # kCFURLVolumeAvailableCapacityForImportantUsageKey + # is undefined. + # With apple_sdk_11_0, there is an issue with + # kColorSyncGenericGrayProfile. + broken = stdenv.hostPlatform.system == "x86_64-darwin"; + longDescription = '' Espanso detects when you type a keyword and replaces it while you're typing. diff --git a/pkgs/applications/office/espanso/inject-wx-on-darwin.patch b/pkgs/applications/office/espanso/inject-wx-on-darwin.patch deleted file mode 100644 index 34b711211927..000000000000 --- a/pkgs/applications/office/espanso/inject-wx-on-darwin.patch +++ /dev/null @@ -1,223 +0,0 @@ -From 6a7400c20831c5ff502c7336d6db2be743f156be Mon Sep 17 00:00:00 2001 -From: Nikola Knezevic -Date: Tue, 16 Aug 2022 22:28:46 +0200 -Subject: [PATCH] Build using system wx on darwin - ---- - espanso-modulo/build.rs | 174 ++++------------------------------------ - 1 file changed, 17 insertions(+), 157 deletions(-) - -diff --git a/espanso-modulo/build.rs b/espanso-modulo/build.rs -index b8b889a..5d972ec 100644 ---- a/espanso-modulo/build.rs -+++ b/espanso-modulo/build.rs -@@ -156,161 +156,6 @@ fn build_native() { - ); - } - --#[cfg(target_os = "macos")] --fn build_native() { -- use std::process::Command; -- -- let project_dir = -- PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").expect("missing CARGO_MANIFEST_DIR")); -- let wx_archive = project_dir.join("vendor").join(WX_WIDGETS_ARCHIVE_NAME); -- if !wx_archive.is_file() { -- panic!("could not find wxWidgets archive!"); -- } -- -- let out_dir = if let Ok(out_path) = std::env::var(WX_WIDGETS_BUILD_OUT_DIR_ENV_NAME) { -- println!( -- "detected wxWidgets build output directory override: {}", -- out_path -- ); -- let path = PathBuf::from(out_path); -- std::fs::create_dir_all(&path).expect("unable to create wxWidgets out dir"); -- path -- } else { -- PathBuf::from(std::env::var("OUT_DIR").expect("missing OUT_DIR")) -- }; -- let out_wx_dir = out_dir.join("wx"); -- println!("wxWidgets will be compiled into: {}", out_wx_dir.display()); -- -- let target_arch = match std::env::var("CARGO_CFG_TARGET_ARCH") -- .expect("unable to read target arch") -- .as_str() -- { -- "x86_64" => "x86_64", -- "aarch64" => "arm64", -- arch => panic!("unsupported arch {}", arch), -- }; -- -- let should_use_ci_m1_workaround = -- std::env::var("CI").unwrap_or_default() == "true" && target_arch == "arm64"; -- -- if !out_wx_dir.is_dir() { -- // Extract the wxWidgets archive -- let wx_archive = -- std::fs::File::open(&wx_archive).expect("unable to open wxWidgets source archive"); -- let mut archive = zip::ZipArchive::new(wx_archive).expect("unable to read wxWidgets archive"); -- archive -- .extract(&out_wx_dir) -- .expect("unable to extract wxWidgets source dir"); -- -- // Compile wxWidgets -- let build_dir = out_wx_dir.join("build-cocoa"); -- std::fs::create_dir_all(&build_dir).expect("unable to create build-cocoa directory"); -- -- let mut handle = if should_use_ci_m1_workaround { -- // Because of a configuration problem on the GitHub CI pipeline, -- // we need to use a series of workarounds to build for M1 machines. -- // See: https://github.com/actions/virtual-environments/issues/3288#issuecomment-830207746 -- Command::new(out_wx_dir.join("configure")) -- .current_dir(build_dir.to_string_lossy().to_string()) -- .args(&[ -- "--disable-shared", -- "--without-libtiff", -- "--without-liblzma", -- "--with-libjpeg=builtin", -- "--with-libpng=builtin", -- "--enable-universal-binary=arm64,x86_64", -- ]) -- .spawn() -- .expect("failed to execute configure") -- } else { -- Command::new(out_wx_dir.join("configure")) -- .current_dir(build_dir.to_string_lossy().to_string()) -- .args(&[ -- "--disable-shared", -- "--without-libtiff", -- "--without-liblzma", -- "--with-libjpeg=builtin", -- "--with-libpng=builtin", -- &format!("--enable-macosx_arch={}", target_arch), -- ]) -- .spawn() -- .expect("failed to execute configure") -- }; -- -- if !handle -- .wait() -- .expect("unable to wait for configure command") -- .success() -- { -- panic!("configure returned non-zero exit code!"); -- } -- -- let mut handle = Command::new("make") -- .current_dir(build_dir.to_string_lossy().to_string()) -- .args(&["-j8"]) -- .spawn() -- .expect("failed to execute make"); -- if !handle -- .wait() -- .expect("unable to wait for make command") -- .success() -- { -- panic!("make returned non-zero exit code!"); -- } -- } -- -- // Make sure wxWidgets is compiled -- if !out_wx_dir.join("build-cocoa").is_dir() { -- panic!("wxWidgets is not compiled correctly, missing 'build-cocoa/' directory") -- } -- -- // If using the M1 CI workaround, convert all the universal libraries to arm64 ones -- // This is needed until https://github.com/rust-lang/rust/issues/55235 is fixed -- if should_use_ci_m1_workaround { -- convert_fat_libraries_to_arm(&out_wx_dir.join("build-cocoa").join("lib")); -- convert_fat_libraries_to_arm(&out_wx_dir.join("build-cocoa")); -- } -- -- let config_path = out_wx_dir.join("build-cocoa").join("wx-config"); -- let cpp_flags = get_cpp_flags(&config_path); -- -- let mut build = cc::Build::new(); -- build -- .cpp(true) -- .file("src/sys/form/form.cpp") -- .file("src/sys/common/common.cpp") -- .file("src/sys/search/search.cpp") -- .file("src/sys/wizard/wizard.cpp") -- .file("src/sys/wizard/wizard_gui.cpp") -- .file("src/sys/welcome/welcome.cpp") -- .file("src/sys/welcome/welcome_gui.cpp") -- .file("src/sys/textview/textview.cpp") -- .file("src/sys/textview/textview_gui.cpp") -- .file("src/sys/troubleshooting/troubleshooting.cpp") -- .file("src/sys/troubleshooting/troubleshooting_gui.cpp") -- .file("src/sys/common/mac.mm"); -- build.flag("-std=c++17"); -- -- for flag in cpp_flags { -- build.flag(&flag); -- } -- -- build.compile("espansomodulosys"); -- -- // Render linker flags -- -- generate_linker_flags(&config_path); -- -- // On (older) OSX we need to link against the clang runtime, -- // which is hidden in some non-default path. -- // -- // More details at https://github.com/alexcrichton/curl-rust/issues/279. -- if let Some(path) = macos_link_search_path() { -- println!("cargo:rustc-link-lib=clang_rt.osx"); -- println!("cargo:rustc-link-search={}", path); -- } --} -- - #[cfg(target_os = "macos")] - fn convert_fat_libraries_to_arm(lib_dir: &Path) { - for entry in -@@ -440,12 +285,17 @@ fn macos_link_search_path() -> Option { - None - } - -+#[cfg(not(target_os = "macos"))] -+fn macos_link_search_path() -> Option { -+ return None -+} -+ - // TODO: add documentation for linux - // Install wxWidgets: - // sudo apt install libwxgtk3.0-0v5 libwxgtk3.0-dev - // - // cargo run --#[cfg(target_os = "linux")] -+#[cfg(not(target_os = "windows"))] - fn build_native() { - // Make sure wxWidgets is installed - // Depending on the installation package, the 'wx-config' command might also be available as 'wx-config-gtk3', -@@ -483,7 +333,8 @@ fn build_native() { - .file("src/sys/textview/textview.cpp") - .file("src/sys/textview/textview_gui.cpp") - .file("src/sys/troubleshooting/troubleshooting.cpp") -- .file("src/sys/troubleshooting/troubleshooting_gui.cpp"); -+ .file("src/sys/troubleshooting/troubleshooting_gui.cpp") -+ .file("src/sys/common/mac.mm"); - build.flag("-std=c++17"); - - for flag in cpp_flags { -@@ -495,6 +346,15 @@ fn build_native() { - // Render linker flags - - generate_linker_flags(&config_path); -+ -+ // On (older) OSX we need to link against the clang runtime, -+ // which is hidden in some non-default path. -+ // -+ // More details at https://github.com/alexcrichton/curl-rust/issues/279. -+ if let Some(path) = macos_link_search_path() { -+ println!("cargo:rustc-link-lib=clang_rt.osx"); -+ println!("cargo:rustc-link-search={}", path); -+ } - } - - fn main() { --- -2.37.1 - diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 70c7e48a82bb..43add667bd6e 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -5135,7 +5135,7 @@ with pkgs; eschalot = callPackage ../tools/security/eschalot { }; espanso = callPackage ../applications/office/espanso { - inherit (darwin.apple_sdk.frameworks) AppKit Cocoa Foundation IOKit Kernel AVFoundation Carbon QTKit AVKit WebKit; + inherit (darwin.apple_sdk_11_0.frameworks) AppKit Cocoa Foundation IOKit Kernel AVFoundation Carbon QTKit AVKit WebKit System; }; espanso-wayland = espanso.override { x11Support = false;