1{ lib, rustPlatform, fetchFromGitHub, pkg-config, installShellFiles, udev, coreutils }:
2
3rustPlatform.buildRustPackage rec {
4 pname = "surface-control";
5 version = "0.4.3-2";
6
7 src = fetchFromGitHub {
8 owner = "linux-surface";
9 repo = pname;
10 rev = "v${version}";
11 sha256 = "sha256-QgkUxT5Ae0agvalZl1ie+1LwxgaTzMrKpQY3KkpWwG4=";
12 };
13
14 cargoLock = {
15 lockFile = ./Cargo.lock;
16 outputHashes = {
17 "sdtx-0.1.3" = "sha256-srYSVXRP/rynhhE3ZfOGRM6c7GDgjfmjO/GLXeTze3A=";
18 };
19 };
20
21 nativeBuildInputs = [ pkg-config installShellFiles ];
22 buildInputs = [ udev ];
23
24 postInstall = ''
25 installShellCompletion \
26 $releaseDir/build/surface-*/out/surface.{bash,fish} \
27 --zsh $releaseDir/build/surface-*/out/_surface
28 install -Dm 0444 -t $out/etc/udev/rules.d \
29 etc/udev/40-surface-control.rules
30 substituteInPlace $out/etc/udev/rules.d/40-surface-control.rules \
31 --replace "/usr/bin/chmod" "${coreutils}/bin/chmod" \
32 --replace "/usr/bin/chown" "${coreutils}/bin/chown"
33 '';
34
35 meta = with lib; {
36 description =
37 "Control various aspects of Microsoft Surface devices on Linux from the Command-Line";
38 homepage = "https://github.com/linux-surface/surface-control";
39 license = licenses.mit;
40 maintainers = with maintainers; [ ];
41 platforms = platforms.linux;
42 };
43}