summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/yk/ykush/package.nix
blob: 7bc503d158c4e4d5652566ad425e98d7030dad08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
{
  lib,
  stdenv,
  fetchFromGitHub,
  libusb1,
  runCommand,
  versionCheckHook,
}:
stdenv.mkDerivation (finalAttrs: {
  pname = "ykushcmd";
  version = "1.4.0";

  buildInputs = [ libusb1 ];

  src = fetchFromGitHub {
    owner = "yepkit";
    repo = "ykush";
    tag = "v${finalAttrs.version}";
    hash = "sha256-+ssr1QHKjEdK8pFkmyHYwG9tY7YHaYcIIJUqaEXixOg=";
  };

  installPhase = ''
    runHook preInstall

    install -D bin/ykushcmd $out/bin/ykushcmd
    install -Dm444 ${./99-ykush.rules} $out/lib/udev/rules.d/99_ykush.rules

    runHook postInstall
  '';

  nativeInstallCheckInputs = [ versionCheckHook ];
  doInstallCheck = true;

  passthru.tests = {
    # We can't run any actual tests without hardware, but we can at least check the binary.
    run-only = runCommand "${finalAttrs.pname}-test" ''
      ${finalAttrs}/bin/ykushcmd -h | grep YKUSHCMD
    '';
  };

  meta = {
    description = "Control utility for YepKit USB hubs";
    longDescription = ''
      controls the features of YepKit USB hubs, allowing one to arbitrarily
      turn ports on and off and otherwise control the hub.
    '';
    homepage = "https://github.com/Yepkit/ykush";
    license = lib.licenses.asl20;
    maintainers = with lib.maintainers; [
      aiyion
      ktemkin
    ];
    mainProgram = "ykushcmd";
    platforms = lib.platforms.linux;
  };
})