From d677a0d3257ffe53546fb18bab7dccb96e5c942d Mon Sep 17 00:00:00 2001 From: Jake Woods Date: Sun, 26 Sep 2021 14:06:30 +1000 Subject: [PATCH 1/2] joycond: unstable-2021-03-27 -> unstable-2021-07-30 This version adds support for "virtual controller" pairing, which lets us use a Pro Controller with Steam and non-steam without collisions. See also: - https://wiki.archlinux.org/title/Gamepad#Using_hid-nintendo_pro_controller_with_Steam_Games_(with_joycond) - https://github.com/ValveSoftware/steam-for-linux/issues/6651#issuecomment-886117867 --- pkgs/os-specific/linux/joycond/default.nix | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pkgs/os-specific/linux/joycond/default.nix b/pkgs/os-specific/linux/joycond/default.nix index a203073b081c..e60e661f0c44 100644 --- a/pkgs/os-specific/linux/joycond/default.nix +++ b/pkgs/os-specific/linux/joycond/default.nix @@ -1,14 +1,14 @@ -{ lib, stdenv, fetchFromGitHub, cmake, pkg-config, libevdev, udev }: +{ lib, stdenv, fetchFromGitHub, cmake, pkg-config, libevdev, udev, acl }: stdenv.mkDerivation rec { pname = "joycond"; - version = "unstable-2021-03-27"; + version = "unstable-2021-07-30"; src = fetchFromGitHub { owner = "DanielOgorchock"; repo = "joycond"; - rev = "2d3f553060291f1bfee2e49fc2ca4a768b289df8"; - sha256 = "0dpmwspll9ar3pxg9rgnh224934par8h8bixdz9i2pqqbc3dqib7"; + rev = "f9a66914622514c13997c2bf7ec20fa98e9dfc1d"; + sha256 = "sha256-quw7yBHDDZk1+6uHthsfMCej7g5uP0nIAqzvI6436B8="; }; nativeBuildInputs = [ cmake pkg-config ]; @@ -25,6 +25,9 @@ stdenv.mkDerivation rec { substituteInPlace $out/etc/systemd/system/joycond.service --replace \ "ExecStart=/usr/bin/joycond" "ExecStart=$out/bin/joycond" + + substituteInPlace $out/etc/udev/rules.d/89-joycond.rules --replace \ + "/bin/setfacl" "${acl}/bin/setfacl" ''; meta = with lib; { From 1af6417b8693fc4ce400269cc2594b41db66f1c9 Mon Sep 17 00:00:00 2001 From: Jake Woods Date: Sun, 26 Sep 2021 14:17:21 +1000 Subject: [PATCH 2/2] nixos/joycond: init NixOS should be able to support the Nintendo Switch Pro controller for steam and non-steam at the same time. Currently there are two mutually exclusive ways to support the Pro Controller: Steam and `hid-nintendo`. Unfortunately these don't work together, but there's a workaround in newer versions of `joycond` (described [here](https://wiki.archlinux.org/title/Gamepad#Using_hid-nintendo_pro_controller_with_Steam_Games_(with_joycond))). To use this workaround `hid-nintendo` and `joycond` need to be updated, and the systemd and udev configuration needs to be made available in NixOS. --- .../from_md/release-notes/rl-2111.section.xml | 8 ++++ .../manual/release-notes/rl-2111.section.md | 2 + nixos/modules/module-list.nix | 1 + nixos/modules/services/hardware/joycond.nix | 40 +++++++++++++++++++ 4 files changed, 51 insertions(+) create mode 100644 nixos/modules/services/hardware/joycond.nix diff --git a/nixos/doc/manual/from_md/release-notes/rl-2111.section.xml b/nixos/doc/manual/from_md/release-notes/rl-2111.section.xml index 98fe3513e254..25f984f9378f 100644 --- a/nixos/doc/manual/from_md/release-notes/rl-2111.section.xml +++ b/nixos/doc/manual/from_md/release-notes/rl-2111.section.xml @@ -321,6 +321,14 @@ programs.pantheon-tweaks. + + + joycond, + a service that uses hid-nintendo to provide + nintendo joycond pairing and better nintendo switch pro + controller support. + +
diff --git a/nixos/doc/manual/release-notes/rl-2111.section.md b/nixos/doc/manual/release-notes/rl-2111.section.md index fef42ec52c9e..40a671e3efa9 100644 --- a/nixos/doc/manual/release-notes/rl-2111.section.md +++ b/nixos/doc/manual/release-notes/rl-2111.section.md @@ -99,6 +99,8 @@ In addition to numerous new and upgraded packages, this release has the followin - [pantheon-tweaks](https://github.com/pantheon-tweaks/pantheon-tweaks), an unofficial system settings panel for Pantheon. Available as [programs.pantheon-tweaks](#opt-programs.pantheon-tweaks.enable). +- [joycond](https://github.com/DanielOgorchock/joycond), a service that uses `hid-nintendo` to provide nintendo joycond pairing and better nintendo switch pro controller support. + ## Backward Incompatibilities {#sec-release-21.11-incompatibilities} - The `security.wrappers` option now requires to always specify an owner, group and whether the setuid/setgid bit should be set. diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index d24f98efb7d3..89cf9c493d67 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -411,6 +411,7 @@ ./services/hardware/illum.nix ./services/hardware/interception-tools.nix ./services/hardware/irqbalance.nix + ./services/hardware/joycond.nix ./services/hardware/lcd.nix ./services/hardware/lirc.nix ./services/hardware/nvidia-optimus.nix diff --git a/nixos/modules/services/hardware/joycond.nix b/nixos/modules/services/hardware/joycond.nix new file mode 100644 index 000000000000..ffef4f8a4e18 --- /dev/null +++ b/nixos/modules/services/hardware/joycond.nix @@ -0,0 +1,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" ]; + }; +}