summary refs log tree commit diff
path: root/nixos/modules/services/hardware/joycond.nix
blob: ffef4f8a4e188b3dde6de7d2a07d7f1e34684b55 (plain) (blame)
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
35
36
37
38
39
40
{ config, lib, pkgs, ... }:

let
  cfg = config.services.joycond;
  kernelPackages = config.boot.kernelPackages;
in

with lib;

{
  options.services.joycond = {
    enable = mkEnableOption "support for Nintendo Pro Controllers and Joycons";

    package = mkOption {
      type = types.package;
      default = pkgs.joycond;
      defaultText = "pkgs.joycond";
      description = ''
        The joycond package to use.
      '';
    };
  };

  config = mkIf cfg.enable {
    environment.systemPackages = [
      kernelPackages.hid-nintendo
      cfg.package
    ];

    boot.extraModulePackages = [ kernelPackages.hid-nintendo ];
    boot.kernelModules = [ "hid_nintendo" ];

    services.udev.packages = [ cfg.package ];

    systemd.packages = [ cfg.package ];

    # Workaround for https://github.com/NixOS/nixpkgs/issues/81138
    systemd.services.joycond.wantedBy = [ "multi-user.target" ];
  };
}