LnL7 / nix-darwin

nix modules for darwin
MIT License
3.09k stars 444 forks source link

services.karabiner-elements is broken after Karabiner-Elements v15.0 #1041

Open rayssd opened 2 months ago

rayssd commented 2 months ago

Hi,

After Karabiner-Elements v15.0, a darwin-rebuild causes the following error:

setting up user launchd services...
creating user service org.nixos.activate_karabiner_system_ext
creating user service org.pqrs.karabiner.agent.karabiner_grabber
cp: cannot stat '/nix/store/fkjp2mw8rmysra1fg3yxcm5n72am4309-launchd/user/Library/LaunchAgents/org.pqrs.karabiner.agent.karabiner_grabber.plist': No such file or directory

Upon inspection, /nix/store/fkjp2mw8rmysra1fg3yxcm5n72am4309-launchd/user/Library/LaunchAgents/org.pqrs.karabiner.agent.karabiner_grabber.plist links to ${pkgs.karabiner-elements}/Library/LaunchAgents/org.pqrs.karabiner.agent.karabiner_observer.plist

The symlinks above are created here: https://github.com/LnL7/nix-darwin/blob/a8968d88e5a537b0491f68ce910749cd870bdbef/modules/services/karabiner-elements/default.nix#L119-L121

${pkgs.karabiner-elements}/Library/LaunchAgents/ is no longer a valid path because the folder LaunchAgents no longer exists in v15.0

It appears this is not the only breaking change though. It seems installing Karabiner-Elements v15.0 using brew introduces two new apps "Karabiner-Elements Non-Priviledged Agent.app" and "Karabiner-Elements Priviledged Daemons.app" in Login Items which weren't there before v15.0.

utkarshgupta137 commented 2 months ago

Did you find any workarounds for this or a way to downgrade karabiner in nixpkgs?

n8henrie commented 2 months ago

@utkarshgupta137 it shouldn't require anything special, something like this is working fine for me (where nixpkgs-stable is a flake input pinned to 24.05).

  nixpkgs.overlays = [
    (_: prev: {
      # https://github.com/LnL7/nix-darwin/issues/1041
      inherit (inputs.nixpkgs-stable.legacyPackages.${prev.system}) karabiner-elements;
    })
  ];
ofalvai commented 2 months ago

I decided to set nix-darwin to follow the stable nixpkgs channel and use the 14.x Karabiner. This was a good reminder for me that OS-level things like nix-darwin should not use unstable packages.

Relevant part of my flake.nix:

nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-24.05";
nix-darwin = {
  url = "github:LnL7/nix-darwin";
  inputs.nixpkgs.follows = "nixpkgs-stable";
};
emilazy commented 2 months ago

I haven’t had the time to look into this but I’d review a PR fixing the module. It would need some conditionals around the package version to support multiple releases (I must cut branches soon…). I wouldn’t say this is particularly an unstable channel thing since it might still be broken by 24.11’s release if nobody gets around to fixing the module.

mvillafuertem commented 1 month ago

@ofalvai thanks it's a nice workaround

I decided to set nix-darwin to follow the stable nixpkgs channel and use the 14.x Karabiner. This was a good reminder for me that OS-level things like nix-darwin should not use unstable packages.

Relevant part of my flake.nix:

nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-24.05";
nix-darwin = {
  url = "github:LnL7/nix-darwin";
  inputs.nixpkgs.follows = "nixpkgs-stable";
};