nixpkgs/pkgs/applications/office/espanso/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

155 lines
3.7 KiB
Nix
Raw Normal View History

{ lib
2020-05-01 17:38:22 +02:00
, fetchFromGitHub
, rustPlatform
, pkg-config
2020-05-01 17:38:22 +02:00
, extra-cmake-modules
2023-05-10 14:22:12 +02:00
, dbus
2020-05-01 17:38:22 +02:00
, libX11
, libXi
, libXtst
, libnotify
2023-05-10 14:22:12 +02:00
, libxkbcommon
2020-05-01 17:38:22 +02:00
, openssl
, xclip
, xdotool
2023-05-10 14:22:12 +02:00
, setxkbmap
, wl-clipboard
, wxGTK32
, makeWrapper
2022-08-31 23:52:00 +02:00
, stdenv
, AppKit
, Cocoa
, Foundation
2023-05-10 14:22:12 +02:00
, IOKit
2023-05-11 11:21:40 +02:00
, Kernel
, AVFoundation
, Carbon
, QTKit
, AVKit
, WebKit
2023-05-10 14:22:12 +02:00
, waylandSupport ? false
, x11Support ? stdenv.isLinux
2023-05-10 15:25:35 +02:00
, testers
, espanso
2020-05-01 17:38:22 +02:00
}:
2023-05-10 14:22:12 +02:00
# espanso does not support building with both X11 and Wayland support at the same time
assert stdenv.isLinux -> x11Support != waylandSupport;
assert stdenv.isDarwin -> !x11Support;
assert stdenv.isDarwin -> !waylandSupport;
2020-05-01 17:38:22 +02:00
rustPlatform.buildRustPackage rec {
pname = "espanso";
2023-05-10 14:22:12 +02:00
version = "2.1.8";
2020-05-01 17:38:22 +02:00
src = fetchFromGitHub {
2023-05-10 14:22:12 +02:00
owner = "espanso";
repo = "espanso";
2020-05-01 17:38:22 +02:00
rev = "v${version}";
2023-05-10 14:22:12 +02:00
hash = "sha256-5TUo5B1UZZARgTHbK2+520e3mGZkZ5tTez1qvZvMnxs=";
2020-05-01 17:38:22 +02:00
};
2023-05-10 14:22:12 +02:00
cargoLock = {
lockFile = ./Cargo.lock;
outputHashes = {
"yaml-rust-0.4.6" = "sha256-wXFy0/s4y6wB3UO19jsLwBdzMy7CGX4JoUt5V6cU7LU=";
};
};
2020-05-01 17:38:22 +02:00
2023-05-11 11:21:40 +02:00
cargoPatches = lib.optionals stdenv.isDarwin [
./inject-wx-on-darwin.patch
];
2020-05-01 17:38:22 +02:00
nativeBuildInputs = [
extra-cmake-modules
pkg-config
makeWrapper
2023-05-10 14:22:12 +02:00
wxGTK32
];
# Ref: https://github.com/espanso/espanso/blob/78df1b704fe2cc5ea26f88fdc443b6ae1df8a989/scripts/build_binary.rs#LL49C3-L62C4
buildNoDefaultFeatures = true;
buildFeatures = [
"modulo"
] ++ lib.optionals waylandSupport[
"wayland"
] ++ lib.optionals stdenv.isLinux [
"vendored-tls"
] ++ lib.optionals stdenv.isDarwin [
"native-tls"
2020-05-01 17:38:22 +02:00
];
buildInputs = [
2023-05-10 14:22:12 +02:00
wxGTK32
2022-08-31 23:52:00 +02:00
] ++ lib.optionals stdenv.isLinux [
2023-05-10 14:22:12 +02:00
openssl
dbus
libnotify
libxkbcommon
2022-08-31 23:52:00 +02:00
] ++ lib.optionals stdenv.isDarwin [
AppKit
Cocoa
Foundation
2023-05-10 14:22:12 +02:00
IOKit
2023-05-11 11:21:40 +02:00
Kernel
AVFoundation
Carbon
QTKit
AVKit
WebKit
2023-05-10 14:22:12 +02:00
] ++ lib.optionals waylandSupport [
wl-clipboard
] ++ lib.optionals x11Support [
libXi
libXtst
libX11
xclip
xdotool
2020-05-01 17:38:22 +02:00
];
postPatch = lib.optionalString stdenv.isDarwin ''
substituteInPlace scripts/create_bundle.sh --replace target/mac/ $out/Applications/
patchShebangs scripts/create_bundle.sh
substituteInPlace espanso/src/res/macos/Info.plist \
--replace "<string>espanso</string>" "<string>${placeholder "out"}/Applications/Espanso.app/Contents/MacOS/espanso</string>"
substituteInPlace espanso/src/res/macos/com.federicoterzi.espanso.plist \
--replace "<string>/Applications/Espanso.app/Contents/MacOS/espanso</string>" "<string>${placeholder "out"}/Applications/Espanso.app/Contents/MacOS/espanso</string>" \
--replace "<string>/usr/bin" "<string>${placeholder "out"}/bin:/usr/bin"
substituteInPlace espanso/src/path/macos.rs espanso/src/path/linux.rs \
--replace '"/usr/local/bin/espanso"' '"${placeholder "out"}/bin/espanso"'
'';
2020-05-01 17:38:22 +02:00
# Some tests require networking
doCheck = false;
postInstall = if stdenv.isDarwin then ''
EXEC_PATH=$out/bin/espanso BUILD_ARCH=current ${stdenv.shell} ./scripts/create_bundle.sh
'' else ''
wrapProgram $out/bin/espanso \
2023-05-10 14:22:12 +02:00
--prefix PATH : ${lib.makeBinPath (
lib.optionals stdenv.isLinux [
libnotify
setxkbmap
] ++ lib.optionals waylandSupport [
wl-clipboard
] ++ lib.optionals x11Support [
xclip
]
)}
'';
2023-05-10 15:25:35 +02:00
passthru.tests.version = testers.testVersion {
package = espanso;
};
meta = with lib; {
2020-05-01 17:38:22 +02:00
description = "Cross-platform Text Expander written in Rust";
homepage = "https://espanso.org";
license = licenses.gpl3Plus;
2023-05-10 14:22:12 +02:00
maintainers = with maintainers; [ kimat thehedgeh0g ];
2022-08-31 23:52:00 +02:00
platforms = platforms.unix;
2020-05-01 17:38:22 +02:00
longDescription = ''
Espanso detects when you type a keyword and replaces it while you're typing.
'';
};
}