24 waylandSupport ? false,
25 x11Support ? stdenv.hostPlatform.isLinux,
29 # espanso does not support building with both X11 and Wayland support at the same time
30 assert stdenv.hostPlatform.isLinux -> x11Support != waylandSupport;
31 assert stdenv.hostPlatform.isDarwin -> !x11Support;
32 assert stdenv.hostPlatform.isDarwin -> !waylandSupport;
33 rustPlatform.buildRustPackage rec {
35 version = "2.2-unstable-2024-05-14";
37 src = fetchFromGitHub {
40 rev = "8daadcc949c35a7b7aa20b7f544fdcff83e2c5f7";
41 hash = "sha256-4MArENBmX6tDVLZE1O8cuJe7A0R+sLZoxBkDvIwIVZ4=";
45 lockFile = ./Cargo.lock;
47 "yaml-rust-0.4.6" = "sha256-wXFy0/s4y6wB3UO19jsLwBdzMy7CGX4JoUt5V6cU7LU=";
58 # Ref: https://github.com/espanso/espanso/blob/78df1b704fe2cc5ea26f88fdc443b6ae1df8a989/scripts/build_binary.rs#LL49C3-L62C4
59 buildNoDefaultFeatures = true;
64 ++ lib.optionals waylandSupport [
67 ++ lib.optionals stdenv.hostPlatform.isLinux [
70 ++ lib.optionals stdenv.hostPlatform.isDarwin [
78 ++ lib.optionals stdenv.hostPlatform.isLinux [
84 ++ lib.optionals stdenv.hostPlatform.isDarwin [
86 (darwinMinVersionHook "10.13")
88 ++ lib.optionals waylandSupport [
91 ++ lib.optionals x11Support [
99 postPatch = lib.optionalString stdenv.hostPlatform.isDarwin ''
100 substituteInPlace scripts/create_bundle.sh \
101 --replace-fail target/mac/ $out/Applications/ \
102 --replace-fail /bin/echo ${coreutils}/bin/echo
103 patchShebangs scripts/create_bundle.sh
104 substituteInPlace espanso/src/res/macos/Info.plist \
105 --replace-fail "<string>espanso</string>" "<string>${placeholder "out"}/Applications/Espanso.app/Contents/MacOS/espanso</string>"
106 substituteInPlace espanso/src/path/macos.rs espanso/src/path/linux.rs \
107 --replace-fail '"/usr/local/bin/espanso"' '"${placeholder "out"}/bin/espanso"'
110 # Some tests require networking
114 if stdenv.hostPlatform.isDarwin then
116 EXEC_PATH=$out/bin/espanso BUILD_ARCH=current ${stdenv.shell} ./scripts/create_bundle.sh
120 wrapProgram $out/bin/espanso \
123 lib.optionals stdenv.hostPlatform.isLinux [
127 ++ lib.optionals waylandSupport [
130 ++ lib.optionals x11Support [
137 passthru.tests.version = testers.testVersion {
139 # remove when updating to a release version
144 description = "Cross-platform Text Expander written in Rust";
145 mainProgram = "espanso";
146 homepage = "https://espanso.org";
147 license = licenses.gpl3Plus;
148 maintainers = with maintainers; [
153 platforms = platforms.unix;
156 Espanso detects when you type a keyword and replaces it while you're typing.