22 , darwinMinVersionHook
23 , waylandSupport ? false
24 , x11Support ? stdenv.hostPlatform.isLinux
28 # espanso does not support building with both X11 and Wayland support at the same time
29 assert stdenv.hostPlatform.isLinux -> x11Support != waylandSupport;
30 assert stdenv.hostPlatform.isDarwin -> !x11Support;
31 assert stdenv.hostPlatform.isDarwin -> !waylandSupport;
32 rustPlatform.buildRustPackage rec {
34 version = "2.2-unstable-2024-05-14";
36 src = fetchFromGitHub {
39 rev = "8daadcc949c35a7b7aa20b7f544fdcff83e2c5f7";
40 hash = "sha256-4MArENBmX6tDVLZE1O8cuJe7A0R+sLZoxBkDvIwIVZ4=";
44 lockFile = ./Cargo.lock;
46 "yaml-rust-0.4.6" = "sha256-wXFy0/s4y6wB3UO19jsLwBdzMy7CGX4JoUt5V6cU7LU=";
57 # Ref: https://github.com/espanso/espanso/blob/78df1b704fe2cc5ea26f88fdc443b6ae1df8a989/scripts/build_binary.rs#LL49C3-L62C4
58 buildNoDefaultFeatures = true;
61 ] ++ lib.optionals waylandSupport [
63 ] ++ lib.optionals stdenv.hostPlatform.isLinux [
65 ] ++ lib.optionals stdenv.hostPlatform.isDarwin [
71 ] ++ lib.optionals stdenv.hostPlatform.isLinux [
76 ] ++ lib.optionals stdenv.hostPlatform.isDarwin [
78 (darwinMinVersionHook "10.13")
79 ] ++ lib.optionals waylandSupport [
81 ] ++ lib.optionals x11Support [
89 postPatch = lib.optionalString stdenv.hostPlatform.isDarwin ''
90 substituteInPlace scripts/create_bundle.sh \
91 --replace-fail target/mac/ $out/Applications/ \
92 --replace-fail /bin/echo ${coreutils}/bin/echo
93 patchShebangs scripts/create_bundle.sh
94 substituteInPlace espanso/src/res/macos/Info.plist \
95 --replace-fail "<string>espanso</string>" "<string>${placeholder "out"}/Applications/Espanso.app/Contents/MacOS/espanso</string>"
96 substituteInPlace espanso/src/path/macos.rs espanso/src/path/linux.rs \
97 --replace-fail '"/usr/local/bin/espanso"' '"${placeholder "out"}/bin/espanso"'
100 # Some tests require networking
104 if stdenv.hostPlatform.isDarwin then ''
105 EXEC_PATH=$out/bin/espanso BUILD_ARCH=current ${stdenv.shell} ./scripts/create_bundle.sh
107 wrapProgram $out/bin/espanso \
108 --prefix PATH : ${lib.makeBinPath (
109 lib.optionals stdenv.hostPlatform.isLinux [
112 ] ++ lib.optionals waylandSupport [
114 ] ++ lib.optionals x11Support [
120 passthru.tests.version = testers.testVersion {
122 # remove when updating to a release version
127 description = "Cross-platform Text Expander written in Rust";
128 mainProgram = "espanso";
129 homepage = "https://espanso.org";
130 license = licenses.gpl3Plus;
131 maintainers = with maintainers; [ kimat pyrox0 n8henrie ];
132 platforms = platforms.unix;
135 Espanso detects when you type a keyword and replaces it while you're typing.