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