diff --git a/packages/tools/system/surface-control/0000-nixos-chmod.patch b/packages/tools/system/surface-control/0000-nixos-chmod.patch new file mode 100644 index 0000000..e4df368 --- /dev/null +++ b/packages/tools/system/surface-control/0000-nixos-chmod.patch @@ -0,0 +1,9 @@ +diff --git a/etc/udev/40-surface-control.rules b/etc/udev/40-surface-control.rules +index db90d63..f5857c8 100644 +--- a/etc/udev/40-surface-control.rules ++++ b/etc/udev/40-surface-control.rules +@@ -1,2 +1,2 @@ +-KERNEL=="01:03:01:00:01", SUBSYSTEM=="surface_aggregator", RUN+="/usr/bin/chmod 664 /sys/bus/surface_aggregator/devices/01:03:01:00:01/perf_mode" +-KERNEL=="01:03:01:00:01", SUBSYSTEM=="surface_aggregator", RUN+="/usr/bin/chown root:surface-control /sys/bus/surface_aggregator/devices/01:03:01:00:01/perf_mode" ++KERNEL=="01:03:01:00:01", SUBSYSTEM=="surface_aggregator", RUN+="@CHMODBINARY@ 664 /sys/bus/surface_aggregator/devices/01:03:01:00:01/perf_mode" ++KERNEL=="01:03:01:00:01", SUBSYSTEM=="surface_aggregator", RUN+="@CHMODBINARY@ root:surface-control /sys/bus/surface_aggregator/devices/01:03:01:00:01/perf_mode" diff --git a/packages/tools/system/surface-control/default.nix b/packages/tools/system/surface-control/default.nix index dc12b73..878f18d 100644 --- a/packages/tools/system/surface-control/default.nix +++ b/packages/tools/system/surface-control/default.nix @@ -1,7 +1,7 @@ { lib , fetchFromGitHub -, rustPlatform +, rustPlatform, coreutils , pkg-config, udev }: @@ -16,6 +16,8 @@ rustPlatform.buildRustPackage rec { sha256 = "0606imcz38kcfxcjs00j3va7j7i8fzr4mcspyh5d6jrwwgl1xjxb"; }; + patches = [ ./0000-nixos-chmod.patch ]; + cargoSha256 = "1yqwaba1rkm3kw1py87j23q4jbdhdsx6fmqidzxgqhr7awrq763y"; nativeBuildInputs = [ pkg-config ]; @@ -24,6 +26,7 @@ rustPlatform.buildRustPackage rec { postInstall = '' mkdir -p $out/lib/udev/rules.d/ cp etc/udev/40-surface-control.rules $out/lib/udev/rules.d/40-surface-control.rules + sed -e "s|@CHMODBINARY@|${coreutils}/bin/chmod|g" --in-place $out/lib/udev/rules.d/40-surface-control.rules ''; doCheck = false;