From 087b4f0a7f745cd8210b46fb4659d965e459b76e Mon Sep 17 00:00:00 2001 From: chn Date: Wed, 13 Dec 2023 22:20:29 +0800 Subject: [PATCH] yoga: try to fix touch keyboard in initrd --- modules/hardware/default.nix | 50 ++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 14 deletions(-) diff --git a/modules/hardware/default.nix b/modules/hardware/default.nix index 3d16cb61..af43c427 100644 --- a/modules/hardware/default.nix +++ b/modules/hardware/default.nix @@ -163,23 +163,13 @@ inputs: { Type = "simple"; WorkingDirectory = "/etc/touch_keyboard"; - # ExecStartPre = let sh = "${inputs.pkgs.bash}/bin/sh"; in - # [ - # ''-${sh} -c "echo 0 > /sys/class/pwm/pwmchip1/export"'' - # ''${sh} -c "echo 0 > /sys/class/pwm/pwmchip1/pwm0/enable"'' - # ''${sh} -c "echo 1 > /sys/class/pwm/pwmchip1/pwm0/enable"'' - # ]; ExecStart = "${keyboard}/bin/touch_keyboard_handler"; }; - yogabook-modes-handler = + yogabook-modes-handler.serviceConfig = { - wantedBy = [ "default.target" ]; - serviceConfig = - { - Type = "simple"; - ExecStart = "${support}/bin/yogabook-modes-handler"; - StandardOutput = "journal"; - }; + Type = "simple"; + ExecStart = "${support}/bin/yogabook-modes-handler"; + StandardOutput = "journal"; }; monitor-sensor = { @@ -192,6 +182,38 @@ inputs: }; }; environment.etc."touch_keyboard".source = "${keyboard}/etc/touch_keyboard"; + boot.initrd = + { + services.udev.packages = [ keyboard support ]; + systemd = + { + extraBin = + { + touch_keyboard_handler = "${keyboard}/bin/touch_keyboard_handler"; + yogabook-modes-handler = "${support}/bin/yogabook-modes-handler"; + }; + services = + { + touch-keyboard-handler = + { + serviceConfig = + { + Type = "simple"; + WorkingDirectory = "/etc/touch_keyboard"; + ExecStart = "${keyboard}/bin/touch_keyboard_handler"; + }; + }; + yogabook-modes-handler.serviceConfig = + { + Type = "simple"; + ExecStart = "${support}/bin/yogabook-modes-handler"; + StandardOutput = "journal"; + }; + }; + + }; + extraFiles."/etc/touch_keyboard".source = "${keyboard}/etc/touch_keyboard"; + }; } )) ];