summaryrefslogtreecommitdiff
path: root/overlays/uhk-agent.nix
blob: fcf66c0b1ca9b47175ae8b7c84a663b0ce8b1d4c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
{ final, prev, sources, ... }:
{
  uhk-agent = 
    let
      image = prev.stdenv.mkDerivation (sources.uhk-agent // {
        buildCommand = ''
          install -m 0644 $src $out
        '';
      });

      appimage-run' = prev.appimage-run.override {
        extraPkgs = p: with p; [
          at-spi2-core
        ];
      };
      
      runScript = prev.writeShellScript "run-uhk-agent" ''
        exec -- ${appimage-run'}/bin/appimage-run ${image}
      '';

      udevRules = prev.writeText "uhk60.rules" ''
        # Ultimate Hacking Keyboard rules
        # These are the udev rules for accessing the USB interfaces of the UHK as non-root users.
        # Copy this file to /etc/udev/rules.d and physically reconnect the UHK afterwards.
        SUBSYSTEM=="input", GROUP="input", MODE="0664"
        SUBSYSTEMS=="usb", ATTRS{idVendor}=="1d50", ATTRS{idProduct}=="612[0-7]", MODE:="0664", GROUP="plugdev"
        KERNEL=="hidraw*", ATTRS{idVendor}=="1d50", ATTRS{idProduct}=="612[0-7]", MODE:="0664", GROUP="plugdev"
      '';
    in prev.runCommand "uhk-agent" {} ''
        mkdir -p $out/bin $out/etc/udev/rules.d
        install -m 0755 ${runScript} $out/bin/uhk-agent
        install -m 0644 ${udevRules} $out/etc/udev/rules.d/50-uhk60.rules
      '';
}