From 3fc483983ba4c0878fa8f184f877b1e70b3a5b00 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Sat, 29 Jun 2024 22:18:11 +1000 Subject: [PATCH 1/5] deckbd: init at 0-unstable-2023-03-16 # Conflicts: # overlay.nix # Conflicts: # overlay.nix --- overlay.nix | 2 ++ pkgs/deckbd/default.nix | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 pkgs/deckbd/default.nix diff --git a/overlay.nix b/overlay.nix index fb71a71c..0a6543b8 100644 --- a/overlay.nix +++ b/overlay.nix @@ -93,4 +93,6 @@ rec { decky-loader = final.callPackage ./pkgs/decky-loader { }; decky-loader-prerelease = final.callPackage ./pkgs/decky-loader/prerelease.nix { }; + + deckbd = final.callPackage ./pkgs/deckbd { }; } diff --git a/pkgs/deckbd/default.nix b/pkgs/deckbd/default.nix new file mode 100644 index 00000000..1d3579b7 --- /dev/null +++ b/pkgs/deckbd/default.nix @@ -0,0 +1,33 @@ +{ lib +, stdenv +, fetchFromGitHub +, pkg-config +, glib +, libevdev +}: + +stdenv.mkDerivation { + pname = "deckbd"; + version = "0-unstable-2023-03-16"; + + src = fetchFromGitHub { + owner = "Ninlives"; + repo = "deckbd"; + rev = "327a8c91159e1b7faa2f12b5e11060b2eb9947a8"; + hash = "sha256-T7iYl1xWtk39XMUUWm1pK0WVm5UK656HmqWHKDmJ220="; + }; + + nativeBuildInputs = [ pkg-config ]; + + buildInputs = [ glib libevdev ]; + + makeFlags = [ "PREFIX=$(out)" ]; + + meta = { + description = "Steam Deck controller keymapper"; + homepage = "https://github.com/Ninlives/deckbd"; + license = lib.licenses.unfree; # https://github.com/Ninlives/deckbd/issues/1 + mainProgram = "deckbd"; + platforms = lib.platforms.linux; + }; +} From 8e5a89697fd779344fedc4ed8a7a18fe52687420 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Sun, 30 Jun 2024 13:33:56 +1000 Subject: [PATCH 2/5] hw-support: Add hid-steam to stage-1 --- modules/devices/steamdeck/hw-support.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/devices/steamdeck/hw-support.nix b/modules/devices/steamdeck/hw-support.nix index 88ca3015..4b96a6ba 100644 --- a/modules/devices/steamdeck/hw-support.nix +++ b/modules/devices/steamdeck/hw-support.nix @@ -46,6 +46,7 @@ in # Gamepad "usbhid" + "hid-steam" ]; boot.initrd.availableKernelModules = [ "nvme" From ea55d824a5a16b1298be6e1eb932194737dac80e Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Sun, 30 Jun 2024 13:36:09 +1000 Subject: [PATCH 3/5] devices/steamdeck: Allow using deckbd during boot --- modules/devices/steamdeck/default.nix | 1 + modules/devices/steamdeck/fde.nix | 105 ++++++++++++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 modules/devices/steamdeck/fde.nix diff --git a/modules/devices/steamdeck/default.nix b/modules/devices/steamdeck/default.nix index a70b55ca..0ee4e007 100644 --- a/modules/devices/steamdeck/default.nix +++ b/modules/devices/steamdeck/default.nix @@ -16,6 +16,7 @@ in imports = [ ./controller.nix ./fan-control.nix + ./fde.nix ./firmware.nix ./graphical.nix ./hw-support.nix diff --git a/modules/devices/steamdeck/fde.nix b/modules/devices/steamdeck/fde.nix new file mode 100644 index 00000000..f1997016 --- /dev/null +++ b/modules/devices/steamdeck/fde.nix @@ -0,0 +1,105 @@ +{ config, lib, pkgs, utils, ... }: + +let + cfg = config.jovian.devices.steamdeck; +in +{ + options = { + jovian.devices.steamdeck = { + fde = { + deckbd = { + enable = lib.mkOption { + default = cfg.enable; + defaultText = lib.literalExpression "config.jovian.devices.steamdeck.enable"; + type = lib.types.bool; + description = '' + Whether to enable deckbd for initrd password entry. + + You may need hold the option key for a second before entering your + password. + ''; + }; + bindsTo = lib.mkOption { + inherit (utils.systemdUtils.unitOptions.commonUnitOptions.options.bindsTo) type; + description = '' + systemd units that require deckbd. + + For example, if you want controller input in unl0kr, add `config.boot.initrd.systemd.services.unl0kr-ask-password.name`. + + Plymouth and the console work by default. + ''; + }; + debug = lib.mkOption { + default = false; + type = lib.types.bool; + description = '' + Enable debug output for deckbd. + + This will log keycodes to the journal. + ''; + }; + }; + }; + }; + }; + + config = lib.mkMerge [ + (lib.mkIf cfg.fde.deckbd.enable { + assertions = [ + { + assertion = cfg.enableDefaultStage1Modules; + message = '' + deckbd cannot be used without the required kernel modules. + + jovian.devices.steamdeck.enableDefaultStage1Modules must be enabled. + ''; + } + { + assertion = config.boot.initrd.systemd.enable; + message = '' + deckbd requires systemd-in-initrd. + + boot.initrd.systemd.enable must be set to true. Note that this may impact other NixOS features. + ''; + } + ]; + + jovian.devices.steamdeck.fde.deckbd.bindsTo = [ + "systemd-ask-password-console.service" + (lib.mkIf config.boot.plymouth.enable config.systemd.services.systemd-ask-password-plymouth.name) + # Note: Agents that have optional keyboard input, such as unl0kr, should not be added here. The user may not want it. + ]; + + boot.initrd = { + kernelModules = [ "uinput" ]; + + services.udev.packages = [ + (pkgs.writeTextDir "lib/udev/rules.d/70-steam-deck-controller.rules" '' + ACTION=="add", SUBSYSTEM=="input", ENV{ID_VENDOR_ID}=="28de", ENV{ID_MODEL_ID}=="1205", ENV{PRODUCT}=="?*", ENV{ID_INPUT_JOYSTICK}=="1", TAG+="systemd", ENV{SYSTEMD_ALIAS}+="/sys/class/input/input_steam_deck_controller" + '') + ]; + + systemd = { + storePaths = with pkgs; [ deckbd ]; # https://github.com/NixOS/nixpkgs/issues/309316 + services.deckbd = { + description = "Steam Deck controller keymapper"; + unitConfig.DefaultDependencies = false; + wantedBy = cfg.fde.deckbd.bindsTo; + before = cfg.fde.deckbd.bindsTo; + inherit (cfg.fde.deckbd) bindsTo; + requires = [ "sys-class-input-input_steam_deck_controller.device" ]; + after = [ "sys-class-input-input_steam_deck_controller.device" ]; + path = with pkgs; [ deckbd ]; + environment.G_MESSAGES_DEBUG = lib.mkIf cfg.fde.deckbd.debug "all"; + # Note: The lizard_mode parameter does not work as intended. The + # Steam Deck must also be manually put into gamepad mode by holding + # the option key for a second. + preStart = "echo 0 > /sys/module/hid_steam/parameters/lizard_mode"; + script = "deckbd"; + postStop = "echo 1 > /sys/module/hid_steam/parameters/lizard_mode"; + }; + }; + }; + }) + ]; +} From 377912dbe4f0dbdd5d96ff12fbd30aa64c5fdc73 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Sun, 7 Jul 2024 18:03:38 +1000 Subject: [PATCH 4/5] deckbd: 0-unstable-2023-03-16 -> 0-unstable-2023-07-01 --- pkgs/deckbd/default.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/deckbd/default.nix b/pkgs/deckbd/default.nix index 1d3579b7..14046f60 100644 --- a/pkgs/deckbd/default.nix +++ b/pkgs/deckbd/default.nix @@ -8,13 +8,13 @@ stdenv.mkDerivation { pname = "deckbd"; - version = "0-unstable-2023-03-16"; + version = "0-unstable-2024-07-01"; src = fetchFromGitHub { owner = "Ninlives"; repo = "deckbd"; - rev = "327a8c91159e1b7faa2f12b5e11060b2eb9947a8"; - hash = "sha256-T7iYl1xWtk39XMUUWm1pK0WVm5UK656HmqWHKDmJ220="; + rev = "1d2c71f2c096fbfa42624dd820a9d11a35c64826"; + hash = "sha256-Svp/5Mo/XkiptbTM3E4QhSRxC6rMeF0t3eTq9BUjLbs="; }; nativeBuildInputs = [ pkg-config ]; @@ -26,7 +26,7 @@ stdenv.mkDerivation { meta = { description = "Steam Deck controller keymapper"; homepage = "https://github.com/Ninlives/deckbd"; - license = lib.licenses.unfree; # https://github.com/Ninlives/deckbd/issues/1 + license = lib.licenses.gpl3Only; mainProgram = "deckbd"; platforms = lib.platforms.linux; }; From 77b2876bc3b1435a360aa3231e71c6a9e513b78f Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Sun, 27 Oct 2024 18:17:17 +1100 Subject: [PATCH 5/5] devices/steamdeck: Clarify deckbd controller instructions --- modules/devices/steamdeck/fde.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/devices/steamdeck/fde.nix b/modules/devices/steamdeck/fde.nix index f1997016..449d1cc3 100644 --- a/modules/devices/steamdeck/fde.nix +++ b/modules/devices/steamdeck/fde.nix @@ -15,8 +15,8 @@ in description = '' Whether to enable deckbd for initrd password entry. - You may need hold the option key for a second before entering your - password. + You must hold the menu button (≡) for a second before entering + your password. ''; }; bindsTo = lib.mkOption { @@ -93,7 +93,7 @@ in environment.G_MESSAGES_DEBUG = lib.mkIf cfg.fde.deckbd.debug "all"; # Note: The lizard_mode parameter does not work as intended. The # Steam Deck must also be manually put into gamepad mode by holding - # the option key for a second. + # the menu button (≡) for a second. preStart = "echo 0 > /sys/module/hid_steam/parameters/lizard_mode"; script = "deckbd"; postStop = "echo 1 > /sys/module/hid_steam/parameters/lizard_mode";