home-manager icon indicating copy to clipboard operation
home-manager copied to clipboard

espanso: add wayland support

Open phanirithvij opened this issue 1 year ago • 4 comments

Tested on kde plasma x11 and wayland sessions. and inside niri wm (wayland). works ok

phanirithvij avatar Oct 04 '24 17:10 phanirithvij

One thing is clear, for it to work seamlessly without explicitly requiring user to choose wayland or x11 the only solution is the upstream espanso package should provide a fat binary (not possible currently).

In this pr the fat binary is package-bin which brings in both the verisons of espanso (x11, wayland) into the store. If and only if both are enabled.

But I guess on darwin there is no such thing as wayland and thus the pkgs.espanso should be chosen always. (edit: made the change, someone with darwin system can try it out)

more things to consider

  • [x] tty (using espanso makes no sense in a tty, I think)
  • [x] override wayland package fix
  • [x] ~shell completions, for the 'fat' binary~ idk how to do that
  • [x] update news.nix

phanirithvij avatar Oct 05 '24 08:10 phanirithvij

so I've tried espanso-wayland = callPackage ../applications/office/espanso { ...; x11 = false; wayland = true; }; in own nixpkgs instance instead of using override and got

$ nix build .#test-espanso-basic-configuration
> --- actual
> +++ expected
> @@ -2,7 +2,7 @@
>  WantedBy=default.target
>
> [Service]
> -ExecStart=/nix/store/nq21hfj3v74hd640ggzvmdd2zgmqv51y-espanso/bin/espanso daemon
> +ExecStart=@espanso@/bin/espanso daemon
> Restart=on-failure

nq21hfj3v74hd640ggzvmdd2zgmqv51y-espanso/bin/espanso here is the package-bin script, and @espanso@ seems to be the pkgs.espanso?

phanirithvij avatar Oct 16 '24 04:10 phanirithvij

Fixed the test (with the @espanso@ stub) but I don't know how to fix the espanso.override attribute missing error.

phanirithvij avatar Oct 16 '24 17:10 phanirithvij

@rycee I need some help, please have a look at it when you're free.

$ nix build .#test-espanso-basic-configuration
error:
       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:34:12:
           33|
           34|   strict = derivationStrict drvAttrs;
             |            ^
           35|

       … while evaluating derivation 'nmt-test-espanso-basic-configuration'
         whose name attribute is located at /nix/store/riqkpszjqk02bi1wppfg8ip5xvh102qd-source/pkgs/stdenv/generic/make-derivation.nix:336:7

       … while evaluating attribute 'buildCommand' of derivation 'nmt-test-espanso-basic-configuration'
         at /nix/store/riqkpszjqk02bi1wppfg8ip5xvh102qd-source/pkgs/build-support/trivial-builders/default.nix:59:17:
           58|         enableParallelBuilding = true;
           59|         inherit buildCommand name;
             |                 ^
           60|         passAsFile = [ "buildCommand" ]

       … while evaluating the option `home.activation.installPackages.data':

       … while evaluating definitions from `/nix/store/vv3xqpi8hwcciy7labjysw3s6qwafch4-source/modules/home-environment.nix':

       … while evaluating the option `services.espanso.package-wayland':

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: attribute 'override' missing
       at /nix/store/riqkpszjqk02bi1wppfg8ip5xvh102qd-source/pkgs/top-level/all-packages.nix:4857:21:
         4856|   };
         4857|   espanso-wayland = espanso.override {
             |                     ^
         4858|     x11Support = false;

phanirithvij avatar Oct 21 '24 03:10 phanirithvij

Thank you for your contribution! I marked this pull request as stale due to inactivity. Please read the relevant sections below before commenting.

If you are the original author of the PR

  • GitHub sometimes doesn't notify people who commented / reviewed a PR previously when you (force) push commits. If you have addressed the reviews you can officially ask for a review from those who commented to you or anyone else.
  • If it is unfinished but you plan to finish it, please mark it as a draft.
  • If you don't expect to work on it any time soon, please consider closing it with a short comment encouraging someone else to pick up your work.
  • To get things rolling again, rebase the PR against the target branch and address valid comments.
If you are not the original author of the PR

  • If you want to pick up the work on this PR, please create a new PR and indicate that it supercedes and closes this PR.

stale[bot] avatar Mar 08 '25 16:03 stale[bot]

still plan to work on this, but need some help with the above.

phanirithvij avatar Mar 11 '25 18:03 phanirithvij

The eval error was fixed in 7a3f0b3b8df1b913890f5fad04d34f2af91da858 no clue where in that commit exactly (git bisect on home-manger)

phanirithvij avatar Apr 26 '25 11:04 phanirithvij

@n8henrie @lucasew @liyangau @bobvanderlinden

phanirithvij avatar Apr 26 '25 14:04 phanirithvij

this is how the UX looks like as of now.

services.espanso.enable = true;
services.espanso = {
    enable = true;
    waylandSupport = false;
};
services.espanso = {
    enable = true;
    x11Support = false;
};

Let me know if I misunderstood something but you're suggesting it to be

services.espanso.enable = true; # UNCHANGED
services.espanso = {
    enable = true;
    package = null;
};
services.espanso = {
    enable = true;
    package-wayland = null;
};

is that right?

if so I'd prefer the first one because I can tell right away what's happening. (and those support option names are the same in espanso package derivation in nixpkgs)

phanirithvij avatar Apr 27 '25 15:04 phanirithvij

Alright, sounds good. Annoying you have to do all this just because of their packaging/runtime issues.

khaneliman avatar Apr 27 '25 16:04 khaneliman