LnL7 / nix-darwin

nix modules for darwin
MIT License
3.19k stars 456 forks source link

skhd binary not in path #969

Closed patmuk closed 1 month ago

patmuk commented 5 months ago

service.skhd.enable doesn't add the binary in path. It is in the nix-store (e.g. /nix/store/dl954m0lama58niyd1cjj3bc15vivih9-skhd-0.3.9/bin/skhd); the launch agent points to it in that location. (However, seems to not stop it.)

However, as hot reloading the configuration is not working (#333) I would have to restart the service, which I neither can't do via I can't restart the service using launchctl launchctl stop org.nixos.skhd (no output in the terminal, shortcuts still work) , nor with skhd -r (command not found: skhd).

patmuk commented 5 months ago

I am on apple silicon with MacOS 14.3.1

joefiorini commented 5 months ago

I'm having this issue as well, along with skhd just not working in general. I also can't control the process with the full path because it wants a service file called $HOME/Library/LaunchAgents/com.koekeishiya.skhd.plist to exist but the name of the actual service file is org.nixos.skhd.plist.

patmuk commented 5 months ago

I figured that restarting the service works for me ... basically `launchctl stop org.nixos.skhd' stops and restarts the service (quietly), which applies the new configuration.

Indeed, the plist sets "KeepAlive"to true.

@joefiorini does it work for you when you run the launchctl command above? As I said, all is silent, so I could only see this by changing a keybinding in services.skhd.skhdConfig in the nix-file.

For any case:

cat ~/Library/LaunchAgents/org.nixos.skhd.plist
───────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: /Users/patmuk/Library/LaunchAgents/org.nixos.skhd.plist
───────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ <?xml version="1.0" encoding="UTF-8"?>
   2   │ <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
   3   │ <plist version="1.0">
   4   │ <dict>
   5   │     <key>EnvironmentVariables</key>
   6   │     <dict>
   7   │         <key>PATH</key>
   8   │         <string>/usr/local/bin:$HOME/.nix-profile/bin:/etc/profiles/per-user/$USER/bin:/run/current-system/sw/bin:/n
       │ ix/var/nix/profiles/default/bin:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin</string>
   9   │     </dict>
  10   │     <key>KeepAlive</key>
  11   │     <true/>
  12   │     <key>Label</key>
  13   │     <string>org.nixos.skhd</string>
  14   │     <key>ProcessType</key>
  15   │     <string>Interactive</string>
  16   │     <key>ProgramArguments</key>
  17   │     <array>
  18   │         <string>/nix/store/dl954m0lama58niyd1cjj3bc15vivih9-skhd-0.3.9/bin/skhd</string>
  19   │         <string>-c</string>
  20   │         <string>/etc/skhdrc</string>
  21   │     </array>
  22   │ </dict>
  23   │ </plist>

But in general: Calling the bin doesn't work, as in skid -r.

joefiorini commented 5 months ago

I figured out that skhd wasn't working for me due to mapping "," in the configuration file. I had to change it to use 0x2B instead. Still have the issue of it not being on my $PATH but that is not really affecting me at the moment.

alex-massa commented 1 month ago

I am also experiencing this issue, currently on Apple silicon running macOS 15.0.1:

$ nix-info
system: "aarch64-darwin", multi-user?: yes, version: nix-env (Nix) 2.18.8, channels(root): "nixpkgs", nixpkgs: /nix/store/mln6wr5z539qgldmsm4j1k8k0dm19yvz-source

Including skhd in the nix-darwin system packages does not help either as that causes a second installation of skhd, which gets correctly placed on path but fails to interact with the service started via the nix-darwin services installation.

One could probably just disable the services installation and use the system package, though that would require installing the service manually via skhd --install-service, which sort of defeats the purpose of using the built-in nix-darwin services option.

Though it should be just a temporary workaround, thanks to your finding I was able to adapt the binding used to restart skhd in my skhdrc file from this:

cmd - escape: skhd --restart-service

to this:

cmd - escape: skhd --restart-service || launchctl stop org.nixos.skhd

On the other hand, yabai is correctly placed on path and bindings that invoke it work just fine:

$ which yabai
/run/current-system/sw/bin/yabai

For clarity, this is the declaration I am using for the services option:

services = {
  skhd.enable = true;
  yabai.enable = true;
};
Enzime commented 1 month ago

I've made a PR #1104 that should add it to the PATH