Skip to content

Commit 1a7de5d

Browse files
authored
usbkvm: init at 0.1.0 (NixOS#369115)
2 parents d8f6bc7 + 777238e commit 1a7de5d

File tree

2 files changed

+112
-0
lines changed

2 files changed

+112
-0
lines changed

pkgs/by-name/us/usbkvm/package.nix

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
{
2+
buildGoModule,
3+
fetchzip,
4+
gst_all_1,
5+
gtkmm3,
6+
hidapi,
7+
lib,
8+
makeWrapper,
9+
meson,
10+
ninja,
11+
pkg-config,
12+
python3,
13+
stdenv,
14+
wrapGAppsHook3,
15+
}:
16+
17+
let
18+
version = "0.1.0";
19+
20+
src = fetchzip {
21+
url = "https://github.com/carrotIndustries/usbkvm/releases/download/v${version}/usbkvm-v${version}.tar.gz";
22+
sha256 = "sha256-OuZ7+IjsvK7/PaiTRwssaQFJDFWJ8HX+kqV13CUyTZA=";
23+
};
24+
25+
ms-tools-lib = buildGoModule {
26+
pname = "usbkvm-ms-tools-lib";
27+
inherit version;
28+
29+
inherit src;
30+
sourceRoot = "source/ms-tools";
31+
vendorHash = "sha256-imHpsos7RDpATSZFWRxug67F7VgjRTT1SkLt7cWk6tU=";
32+
33+
buildInputs = [
34+
hidapi
35+
];
36+
37+
buildPhase = ''
38+
mkdir -p $out/
39+
go build -C lib/ -o $out/ -buildmode=c-archive mslib.go
40+
'';
41+
};
42+
in
43+
stdenv.mkDerivation {
44+
pname = "usbkvm";
45+
inherit version src;
46+
47+
nativeBuildInputs = [
48+
pkg-config
49+
python3
50+
meson
51+
ninja
52+
makeWrapper
53+
wrapGAppsHook3
54+
];
55+
56+
buildInputs = [
57+
gst_all_1.gstreamer
58+
gtkmm3
59+
hidapi
60+
];
61+
62+
# The package includes instructions to build the "mslib.{a,h}" files using a
63+
# Go compiler, but that doesn't work in the Nix sandbox. We patch out this
64+
# build step to instead copy those files from the Nix store:
65+
patches = [
66+
./precompiled-mslib.patch
67+
];
68+
postPatch = ''
69+
substituteInPlace meson.build \
70+
--replace-fail "@MSLIB_A_PRECOMPILED@" "${ms-tools-lib}/mslib.a" \
71+
--replace-fail "@MSLIB_H_PRECOMPILED@" "${ms-tools-lib}/mslib.h"
72+
'';
73+
74+
postFixup =
75+
let
76+
GST_PLUGIN_PATH = lib.makeSearchPathOutput "lib" "lib/gstreamer-1.0" [
77+
gst_all_1.gst-plugins-base
78+
(gst_all_1.gst-plugins-good.override { gtkSupport = true; })
79+
];
80+
in
81+
lib.optionalString stdenv.hostPlatform.isLinux ''
82+
wrapProgram $out/bin/usbkvm \
83+
--prefix GST_PLUGIN_PATH : "${GST_PLUGIN_PATH}"
84+
'';
85+
86+
postInstall = ''
87+
mkdir -p $out/lib/udev/rules.d/
88+
cp ../70-usbkvm.rules $out/lib/udev/rules.d/
89+
'';
90+
91+
meta = {
92+
homepage = "https://github.com/carrotIndustries/usbkvm";
93+
description = "An open-source USB KVM (Keyboard, Video and Mouse) adapter";
94+
changelog = "https://github.com/carrotIndustries/usbkvm/releases/tag/v${version}";
95+
license = lib.licenses.gpl3;
96+
maintainers = with lib.maintainers; [ lschuermann ];
97+
mainProgram = "usbkvm";
98+
};
99+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/meson.build b/meson.build
2+
index 6e60b0b..b25da9d 100644
3+
--- a/meson.build
4+
+++ b/meson.build
5+
@@ -125,7 +125,7 @@ mslib = custom_target(
6+
'mslib',
7+
output: ['mslib.a', 'mslib.h'],
8+
input: 'ms-tools/lib/mslib.go',
9+
- command: ['go', 'build', '-C', join_paths(meson.current_source_dir(), 'ms-tools/lib'), '-o', join_paths(meson.current_build_dir(), '@OUTPUT0@'), '-buildmode=c-archive', 'mslib.go']
10+
+ command: ['cp', '@MSLIB_A_PRECOMPILED@', '@MSLIB_H_PRECOMPILED@', join_paths(meson.current_build_dir(), '@OUTDIR@')]
11+
12+
)
13+

0 commit comments

Comments
 (0)