From 6769536ec7eebdfae4620c9c2197f9bcb499f06b Mon Sep 17 00:00:00 2001 From: Toast Date: Thu, 25 Jan 2024 09:23:07 +0100 Subject: [PATCH] Flake: add nixpkgs pr 277661 --- flake.nix | 1 + nixpkgs-patches/pr277661.patch | 336 +++++++++++++++++++++++++++++++++ 2 files changed, 337 insertions(+) create mode 100644 nixpkgs-patches/pr277661.patch diff --git a/flake.nix b/flake.nix index 3a37f46..57d78bc 100644 --- a/flake.nix +++ b/flake.nix @@ -81,6 +81,7 @@ src = nixpkgs-unstable-raw; patches = [ ./nixpkgs-patches/pr281207.patch + ./nixpkgs-patches/pr277661.patch ]; }; nixpkgs-patched = nixpkgs-raw.legacyPackages.x86_64-linux.applyPatches { diff --git a/nixpkgs-patches/pr277661.patch b/nixpkgs-patches/pr277661.patch new file mode 100644 index 0000000..17ec03c --- /dev/null +++ b/nixpkgs-patches/pr277661.patch @@ -0,0 +1,336 @@ +From bcf9a24332a04ddcef154b792697320d40829820 Mon Sep 17 00:00:00 2001 +From: Brenton Simpson +Date: Mon, 1 Jan 2024 16:18:45 -0800 +Subject: [PATCH 1/5] handheld-daemon: init at 0.2.7 + +--- + .../manual/release-notes/rl-2405.section.md | 2 + + nixos/modules/module-list.nix | 1 + + .../services/hardware/handheld-daemon.nix | 43 +++++++++++++++ + pkgs/by-name/ha/handheld-daemon/package.nix | 54 +++++++++++++++++++ + 4 files changed, 100 insertions(+) + create mode 100644 nixos/modules/services/hardware/handheld-daemon.nix + create mode 100644 pkgs/by-name/ha/handheld-daemon/package.nix + +diff --git a/nixos/doc/manual/release-notes/rl-2405.section.md b/nixos/doc/manual/release-notes/rl-2405.section.md +index f4434fd6b94cac..3ddc2f781bd968 100644 +--- a/nixos/doc/manual/release-notes/rl-2405.section.md ++++ b/nixos/doc/manual/release-notes/rl-2405.section.md +@@ -22,6 +22,8 @@ In addition to numerous new and upgraded packages, this release has the followin + + + ++- [Handheld Daemon](https://github.com/hhd-dev/hhd), support for gaming handhelds like the Legion Go, ROG Ally, and GPD Win. Available as [services.handheldDaemon](#opt-services.handheldDaemon.enable). ++ + - [Guix](https://guix.gnu.org), a functional package manager inspired by Nix. Available as [services.guix](#opt-services.guix.enable). + + - [maubot](https://github.com/maubot/maubot), a plugin-based Matrix bot framework. Available as [services.maubot](#opt-services.maubot.enable). +diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix +index 00e6240f531d52..154fd8df2ce08d 100644 +--- a/nixos/modules/module-list.nix ++++ b/nixos/modules/module-list.nix +@@ -532,6 +532,7 @@ + ./services/hardware/fancontrol.nix + ./services/hardware/freefall.nix + ./services/hardware/fwupd.nix ++ ./services/hardware/handheld-daemon.nix + ./services/hardware/hddfancontrol.nix + ./services/hardware/illum.nix + ./services/hardware/interception-tools.nix +diff --git a/nixos/modules/services/hardware/handheld-daemon.nix b/nixos/modules/services/hardware/handheld-daemon.nix +new file mode 100644 +index 00000000000000..a513ed7ddf8efe +--- /dev/null ++++ b/nixos/modules/services/hardware/handheld-daemon.nix +@@ -0,0 +1,43 @@ ++{ config ++, lib ++, pkgs ++, ... ++}: ++with lib; let ++ cfg = config.services.handheldDaemon; ++in ++{ ++ options.services.handheldDaemon = { ++ enable = mkEnableOption "Enable Handheld Daemon"; ++ ++ user = mkOption { ++ type = types.str; ++ description = lib.mdDoc '' ++ The user to run Handheld Daemon with. ++ ''; ++ }; ++ }; ++ ++ config = mkIf cfg.enable { ++ environment.systemPackages = [ pkgs.handheld-daemon ]; ++ services.udev.packages = [ pkgs.handheld-daemon ]; ++ systemd.packages = [ pkgs.handheld-daemon ]; ++ ++ systemd.services.handheldDaemon = { ++ description = "Handheld Daemon"; ++ ++ wantedBy = [ "multi-user.target" ]; ++ ++ restartIfChanged = true; ++ ++ serviceConfig = { ++ ExecStart = "${ pkgs.handheld-daemon }/bin/hhd --user ${ cfg.user }"; ++ Nice = "-12"; ++ Restart = "on-failure"; ++ RestartSec = "10"; ++ }; ++ }; ++ }; ++ ++ meta.maintainers = [ maintainers.appsforartists ]; ++} +diff --git a/pkgs/by-name/ha/handheld-daemon/package.nix b/pkgs/by-name/ha/handheld-daemon/package.nix +new file mode 100644 +index 00000000000000..b8b14d85f45bf7 +--- /dev/null ++++ b/pkgs/by-name/ha/handheld-daemon/package.nix +@@ -0,0 +1,54 @@ ++{ config ++, fetchFromGitHub ++, hidapi ++, lib ++, python3 ++, ++}: ++python3.pkgs.buildPythonApplication rec { ++ pname = "handheld-daemon"; ++ version = "0.2.7"; ++ format = "pyproject"; ++ ++ src = fetchFromGitHub { ++ owner = "hhd-dev"; ++ repo = "hhd"; ++ rev = "ccae6b207cadfbdaef292270c4fc6c855f71ba03"; ++ hash = "sha256-+tyiXOvZXLbomhgFRKUNKGbkkkOxQKdk/kjeWZ4pvO0="; ++ }; ++ ++ pythonPath = with python3.pkgs; [ ++ evdev ++ pyyaml ++ rich ++ ]; ++ ++ nativeBuildInputs = with python3.pkgs; [ ++ setuptools ++ ]; ++ ++ propagatedBuildInputs = [ ++ hidapi ++ ]; ++ ++ # handheld-daemon contains a fork of the python module `hid`, so this hook ++ # is borrowed from the `hid` derivation. ++ postPatch = '' ++ hidapi=${ hidapi }/lib/ ++ test -d $hidapi || { echo "ERROR: $hidapi doesn't exist, please update/fix this build expression."; exit 1; } ++ sed -i -e "s|libhidapi|$hidapi/libhidapi|" src/hhd/controller/lib/hid.py ++ ''; ++ ++ postInstall = '' ++ install -Dm644 $src/usr/lib/udev/rules.d/83-hhd.rules -t $out/lib/udev/rules.d/ ++ ''; ++ ++ meta = with lib; { ++ homepage = "https://github.com/hhd-dev/hhd/"; ++ description = "Linux support for gaming handhelds"; ++ platforms = platforms.linux; ++ license = licenses.mit; ++ maintainers = with maintainers; [ appsforartists ]; ++ mainProgram = "hhd"; ++ }; ++} + +From 52f22bfc57dff00a93343e30a42e434b68062196 Mon Sep 17 00:00:00 2001 +From: Brenton Simpson +Date: Wed, 17 Jan 2024 09:52:06 -0800 +Subject: [PATCH 2/5] handheld-daemon: 0.27 -> 1.0.8 + +--- + pkgs/by-name/ha/handheld-daemon/package.nix | 7 +++---- + 1 file changed, 3 insertions(+), 4 deletions(-) + +diff --git a/pkgs/by-name/ha/handheld-daemon/package.nix b/pkgs/by-name/ha/handheld-daemon/package.nix +index b8b14d85f45bf7..f590665a8292fa 100644 +--- a/pkgs/by-name/ha/handheld-daemon/package.nix ++++ b/pkgs/by-name/ha/handheld-daemon/package.nix +@@ -3,18 +3,17 @@ + , hidapi + , lib + , python3 +-, + }: + python3.pkgs.buildPythonApplication rec { + pname = "handheld-daemon"; +- version = "0.2.7"; ++ version = "1.0.8"; + format = "pyproject"; + + src = fetchFromGitHub { + owner = "hhd-dev"; + repo = "hhd"; +- rev = "ccae6b207cadfbdaef292270c4fc6c855f71ba03"; +- hash = "sha256-+tyiXOvZXLbomhgFRKUNKGbkkkOxQKdk/kjeWZ4pvO0="; ++ rev = "6cb83a9833eebc81bd27bed57eb68ece15cdd7a6"; ++ hash = "sha256-YfBi5UKaB+v+eDI8rcvqkogAYRU2kTc0NqvakhKxBOE="; + }; + + pythonPath = with python3.pkgs; [ + +From f571033ce013a416c744bd3d3ffc0fe525dbe3a9 Mon Sep 17 00:00:00 2001 +From: Brenton Simpson +Date: Sat, 20 Jan 2024 17:56:44 -0800 +Subject: [PATCH 3/5] handheld-daemon: use kebab-case instead of camelCase for + service name + +--- + nixos/doc/manual/release-notes/rl-2405.section.md | 2 +- + nixos/modules/services/hardware/handheld-daemon.nix | 6 +++--- + 2 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/nixos/doc/manual/release-notes/rl-2405.section.md b/nixos/doc/manual/release-notes/rl-2405.section.md +index 3ddc2f781bd968..994f642154619c 100644 +--- a/nixos/doc/manual/release-notes/rl-2405.section.md ++++ b/nixos/doc/manual/release-notes/rl-2405.section.md +@@ -22,7 +22,7 @@ In addition to numerous new and upgraded packages, this release has the followin + + + +-- [Handheld Daemon](https://github.com/hhd-dev/hhd), support for gaming handhelds like the Legion Go, ROG Ally, and GPD Win. Available as [services.handheldDaemon](#opt-services.handheldDaemon.enable). ++- [Handheld Daemon](https://github.com/hhd-dev/hhd), support for gaming handhelds like the Legion Go, ROG Ally, and GPD Win. Available as [services.handheld-daemon](#opt-services.handheld-daemon.enable). + + - [Guix](https://guix.gnu.org), a functional package manager inspired by Nix. Available as [services.guix](#opt-services.guix.enable). + +diff --git a/nixos/modules/services/hardware/handheld-daemon.nix b/nixos/modules/services/hardware/handheld-daemon.nix +index a513ed7ddf8efe..81859bf5b122fe 100644 +--- a/nixos/modules/services/hardware/handheld-daemon.nix ++++ b/nixos/modules/services/hardware/handheld-daemon.nix +@@ -4,10 +4,10 @@ + , ... + }: + with lib; let +- cfg = config.services.handheldDaemon; ++ cfg = config.services.handheld-daemon; + in + { +- options.services.handheldDaemon = { ++ options.services.handheld-daemon = { + enable = mkEnableOption "Enable Handheld Daemon"; + + user = mkOption { +@@ -23,7 +23,7 @@ in + services.udev.packages = [ pkgs.handheld-daemon ]; + systemd.packages = [ pkgs.handheld-daemon ]; + +- systemd.services.handheldDaemon = { ++ systemd.services.handheld-daemon = { + description = "Handheld Daemon"; + + wantedBy = [ "multi-user.target" ]; + +From 75516996fe8b29d970e2eae003c67c07ef3ae206 Mon Sep 17 00:00:00 2001 +From: Brenton Simpson +Date: Mon, 22 Jan 2024 11:12:04 -0800 +Subject: [PATCH 4/5] handheld-daemon: make package overrideable + +Co-authored-by: h7x4 +--- + nixos/modules/services/hardware/handheld-daemon.nix | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +diff --git a/nixos/modules/services/hardware/handheld-daemon.nix b/nixos/modules/services/hardware/handheld-daemon.nix +index 81859bf5b122fe..154380985bf05d 100644 +--- a/nixos/modules/services/hardware/handheld-daemon.nix ++++ b/nixos/modules/services/hardware/handheld-daemon.nix +@@ -9,6 +9,7 @@ in + { + options.services.handheld-daemon = { + enable = mkEnableOption "Enable Handheld Daemon"; ++ package = mkPackageOption pkgs "handheld-daemon" { }; + + user = mkOption { + type = types.str; +@@ -19,9 +20,9 @@ in + }; + + config = mkIf cfg.enable { +- environment.systemPackages = [ pkgs.handheld-daemon ]; +- services.udev.packages = [ pkgs.handheld-daemon ]; +- systemd.packages = [ pkgs.handheld-daemon ]; ++ environment.systemPackages = [ cfg.package ]; ++ services.udev.packages = [ cfg.package ]; ++ systemd.packages = [ cfg.package ]; + + systemd.services.handheld-daemon = { + description = "Handheld Daemon"; +@@ -31,7 +32,7 @@ in + restartIfChanged = true; + + serviceConfig = { +- ExecStart = "${ pkgs.handheld-daemon }/bin/hhd --user ${ cfg.user }"; ++ ExecStart = "${ cfg.package }/bin/hhd --user ${ cfg.user }"; + Nice = "-12"; + Restart = "on-failure"; + RestartSec = "10"; + +From 3bc83885805347e099ab0e6469875b23edb5698e Mon Sep 17 00:00:00 2001 +From: Brenton Simpson +Date: Mon, 22 Jan 2024 11:13:15 -0800 +Subject: [PATCH 5/5] handheld-daemon: 1.0.8 -> 1.1.0 + +--- + pkgs/by-name/ha/handheld-daemon/package.nix | 17 +++++++++-------- + 1 file changed, 9 insertions(+), 8 deletions(-) + +diff --git a/pkgs/by-name/ha/handheld-daemon/package.nix b/pkgs/by-name/ha/handheld-daemon/package.nix +index f590665a8292fa..e037c4da70868b 100644 +--- a/pkgs/by-name/ha/handheld-daemon/package.nix ++++ b/pkgs/by-name/ha/handheld-daemon/package.nix +@@ -1,19 +1,21 @@ + { config + , fetchFromGitHub + , hidapi ++, kmod + , lib + , python3 ++, toybox + }: + python3.pkgs.buildPythonApplication rec { + pname = "handheld-daemon"; +- version = "1.0.8"; ++ version = "1.1.0"; + format = "pyproject"; + + src = fetchFromGitHub { + owner = "hhd-dev"; + repo = "hhd"; +- rev = "6cb83a9833eebc81bd27bed57eb68ece15cdd7a6"; +- hash = "sha256-YfBi5UKaB+v+eDI8rcvqkogAYRU2kTc0NqvakhKxBOE="; ++ rev = "abe34c6841476f5b41afe30ee18ff3e510402d68"; ++ hash = "sha256-ovLC1BQ98jUaDEMPBzWma4TYSzTF+yE/cMemFdJmqlE="; + }; + + pythonPath = with python3.pkgs; [ +@@ -22,12 +24,11 @@ python3.pkgs.buildPythonApplication rec { + rich + ]; + +- nativeBuildInputs = with python3.pkgs; [ +- setuptools +- ]; +- +- propagatedBuildInputs = [ ++ propagatedBuildInputs = with python3.pkgs; [ + hidapi ++ kmod ++ setuptools ++ toybox + ]; + + # handheld-daemon contains a fork of the python module `hid`, so this hook