-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
{ | ||
buildGoModule, | ||
fetchzip, | ||
gst_all_1, | ||
gtkmm3, | ||
hidapi, | ||
lib, | ||
makeWrapper, | ||
meson, | ||
ninja, | ||
pkg-config, | ||
python3, | ||
stdenv, | ||
wrapGAppsHook3, | ||
}: | ||
|
||
let | ||
version = "0.1.0"; | ||
|
||
src = fetchzip { | ||
url = "https://github.com/carrotIndustries/usbkvm/releases/download/v${version}/usbkvm-v${version}.tar.gz"; | ||
sha256 = "sha256-OuZ7+IjsvK7/PaiTRwssaQFJDFWJ8HX+kqV13CUyTZA="; | ||
}; | ||
|
||
ms-tools-lib = buildGoModule { | ||
pname = "usbkvm-ms-tools-lib"; | ||
inherit version; | ||
|
||
inherit src; | ||
sourceRoot = "source/ms-tools"; | ||
vendorHash = "sha256-imHpsos7RDpATSZFWRxug67F7VgjRTT1SkLt7cWk6tU="; | ||
|
||
buildInputs = [ | ||
hidapi | ||
]; | ||
|
||
buildPhase = '' | ||
mkdir -p $out/ | ||
go build -C lib/ -o $out/ -buildmode=c-archive mslib.go | ||
''; | ||
}; | ||
in | ||
stdenv.mkDerivation { | ||
pname = "usbkvm"; | ||
inherit version src; | ||
|
||
nativeBuildInputs = [ | ||
pkg-config | ||
python3 | ||
meson | ||
ninja | ||
makeWrapper | ||
wrapGAppsHook3 | ||
]; | ||
|
||
buildInputs = [ | ||
gst_all_1.gstreamer | ||
gtkmm3 | ||
hidapi | ||
]; | ||
|
||
# The package includes instructions to build the "mslib.{a,h}" files using a | ||
# Go compiler, but that doesn't work in the Nix sandbox. We patch out this | ||
# build step to instead copy those files from the Nix store: | ||
patches = [ | ||
./precompiled-mslib.patch | ||
]; | ||
postPatch = '' | ||
substituteInPlace meson.build \ | ||
--replace-fail "@MSLIB_A_PRECOMPILED@" "${ms-tools-lib}/mslib.a" \ | ||
--replace-fail "@MSLIB_H_PRECOMPILED@" "${ms-tools-lib}/mslib.h" | ||
''; | ||
|
||
postFixup = | ||
let | ||
GST_PLUGIN_PATH = lib.makeSearchPathOutput "lib" "lib/gstreamer-1.0" [ | ||
gst_all_1.gst-plugins-base | ||
(gst_all_1.gst-plugins-good.override { gtkSupport = true; }) | ||
]; | ||
in | ||
lib.optionalString stdenv.hostPlatform.isLinux '' | ||
wrapProgram $out/bin/usbkvm \ | ||
--prefix GST_PLUGIN_PATH : "${GST_PLUGIN_PATH}" | ||
''; | ||
|
||
postInstall = '' | ||
mkdir -p $out/lib/udev/rules.d/ | ||
cp ../70-usbkvm.rules $out/lib/udev/rules.d/ | ||
''; | ||
|
||
meta = { | ||
homepage = "https://github.com/carrotIndustries/usbkvm"; | ||
description = "An open-source USB KVM (Keyboard, Video and Mouse) adapter"; | ||
changelog = "https://github.com/carrotIndustries/usbkvm/releases/tag/v${version}"; | ||
license = lib.licenses.gpl3; | ||
maintainers = with lib.maintainers; [ lschuermann ]; | ||
mainProgram = "usbkvm"; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git a/meson.build b/meson.build | ||
index 6e60b0b..b25da9d 100644 | ||
--- a/meson.build | ||
+++ b/meson.build | ||
@@ -125,7 +125,7 @@ mslib = custom_target( | ||
'mslib', | ||
output: ['mslib.a', 'mslib.h'], | ||
input: 'ms-tools/lib/mslib.go', | ||
- 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'] | ||
+ command: ['cp', '@MSLIB_A_PRECOMPILED@', '@MSLIB_H_PRECOMPILED@', join_paths(meson.current_build_dir(), '@OUTDIR@')] | ||
|
||
) | ||
|