mirror of
https://github.com/nix-community/home-manager.git
synced 2026-01-12 01:59:37 +08:00
espanso: add crossplatform support
Co-authored-by: Austin Horstman <khaneliman12@gmail.com> Signed-off-by: phanirithvij <phanirithvij2000@gmail.com>
This commit is contained in:
committed by
Austin Horstman
parent
1d2f0b3d4b
commit
29fce40e13
11
modules/misc/news/2025-04-26_18-56-13.nix
Normal file
11
modules/misc/news/2025-04-26_18-56-13.nix
Normal file
@@ -0,0 +1,11 @@
|
||||
{ pkgs, config, ... }:
|
||||
{
|
||||
time = "2025-04-26T13:26:13+00:00";
|
||||
condition = pkgs.hostPlatform.isLinux && config.services.espanso.enable;
|
||||
message = ''
|
||||
`services.espanso` now supports wayland.
|
||||
This is enabled by default on Linux as `services.espanso.waylandSupport = true;`.
|
||||
Depending on your graphical session type, you may disable one of `services.espanso.x11Support` and `services.espanso.waylandSupport` to reduce the closure size of espanso on your system.
|
||||
Both x11 and wayland versions come enabled by default on Linux.
|
||||
'';
|
||||
}
|
||||
@@ -7,6 +7,7 @@
|
||||
let
|
||||
inherit (lib)
|
||||
mkOption
|
||||
mkPackageOption
|
||||
mkEnableOption
|
||||
mkIf
|
||||
maintainers
|
||||
@@ -16,9 +17,25 @@ let
|
||||
versionAtLeast
|
||||
;
|
||||
|
||||
inherit (pkgs.stdenv.hostPlatform) isLinux;
|
||||
|
||||
cfg = config.services.espanso;
|
||||
espansoVersion = cfg.package.version;
|
||||
|
||||
package-bin =
|
||||
if isLinux && cfg.x11Support && cfg.waylandSupport then
|
||||
pkgs.writeShellScriptBin "espanso" ''
|
||||
if [ -n "$WAYLAND_DISPLAY" ]; then
|
||||
${lib.meta.getExe cfg.package-wayland} "$@"
|
||||
else
|
||||
${lib.meta.getExe cfg.package} "$@"
|
||||
fi
|
||||
''
|
||||
else if isLinux && cfg.waylandSupport then
|
||||
cfg.package-wayland
|
||||
else
|
||||
cfg.package;
|
||||
|
||||
yaml = pkgs.formats.yaml { };
|
||||
in
|
||||
{
|
||||
@@ -47,6 +64,29 @@ in
|
||||
defaultText = literalExpression "pkgs.espanso";
|
||||
};
|
||||
|
||||
package-wayland =
|
||||
mkPackageOption pkgs "espanso-wayland" {
|
||||
nullable = true;
|
||||
extraDescription = "Which `espanso` package to use when running under wayland.";
|
||||
}
|
||||
// {
|
||||
default = if isLinux && cfg.waylandSupport then pkgs.espanso-wayland else null;
|
||||
};
|
||||
|
||||
x11Support = mkOption {
|
||||
type = types.bool;
|
||||
description = "Whether to enable x11 support on linux";
|
||||
default = isLinux;
|
||||
defaultText = "`true` on linux";
|
||||
};
|
||||
|
||||
waylandSupport = mkOption {
|
||||
type = types.bool;
|
||||
description = "Whether to enable wayland support on linux";
|
||||
default = isLinux;
|
||||
defaultText = "`true` on linux";
|
||||
};
|
||||
|
||||
configs = mkOption {
|
||||
type = yaml.type;
|
||||
default = {
|
||||
@@ -126,9 +166,16 @@ in
|
||||
The services.espanso module only supports Espanso version 2 or later.
|
||||
'';
|
||||
}
|
||||
{
|
||||
assertion = isLinux -> (cfg.x11Support || cfg.waylandSupport);
|
||||
message = ''
|
||||
In services.espanso at least one of x11 or wayland support must be enabled on linux.
|
||||
'';
|
||||
}
|
||||
];
|
||||
|
||||
home.packages = [ cfg.package ];
|
||||
# conflicting to have cfg.package and cfg.package-wayland
|
||||
home.packages = [ package-bin ];
|
||||
|
||||
xdg.configFile =
|
||||
let
|
||||
@@ -152,7 +199,7 @@ in
|
||||
Description = "Espanso: cross platform text expander in Rust";
|
||||
};
|
||||
Service = {
|
||||
ExecStart = "${cfg.package}/bin/espanso launcher";
|
||||
ExecStart = "${lib.meta.getExe package-bin} launcher";
|
||||
Restart = "on-failure";
|
||||
RestartSec = 3;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user