Unverified Commit 6eaf89b6 authored by Gaétan Lepage's avatar Gaétan Lepage Committed by GitHub
Browse files

usbkvm: 0.2.0 -> 0.3.0 (#417085)

parents 7cb5dff9 74e44280
Loading
Loading
Loading
Loading
+31 −22
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  buildGoModule,
  fetchzip,
  gst_all_1,
  gtkmm3,
  hidapi,
  lib,
  makeWrapper,
  meson,
  ninja,
  pkg-config,
  python3,
  stdenv,
  udev,
  wrapGAppsHook3,
}:

let
  version = "0.2.0";
  version = "0.3.0";

  src = fetchzip {
    url = "https://github.com/carrotIndustries/usbkvm/releases/download/v${version}/usbkvm-v${version}.tar.gz";
    sha256 = "sha256-ng6YpaN7sKEBPJcJAm0kcYtT++orweWRx6uOZFnOGG8=";
    hash = "sha256-urexPODXU69QfSRHtJVpoDx/6mbPcv6EQ3mR0VRHNiY=";
  };

  ms-tools-lib = buildGoModule {
    pname = "usbkvm-ms-tools-lib";
    inherit version;
    inherit version src;

    inherit src;
    sourceRoot = "${src.name}/ms-tools";

    vendorHash = null; # dependencies are vendored in the release tarball

    buildInputs = [
      hidapi
    ];
    buildInputs = [ hidapi ];

    buildPhase = ''
      runHook preBuild

      mkdir -p $out/
      go build -C lib/ -o $out/ -buildmode=c-archive mslib.go

      runHook postBuild
    '';

    meta = {
      homepage = "https://github.com/carrotIndustries/ms-tools";
      description = "Program, library and reference designs to develop for MacroSilicon MS2106/MS2109/MS2130 chips";
      license = lib.licenses.mit;
    };
  };
in
stdenv.mkDerivation {
  pname = "usbkvm";
  inherit version src;

  # 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"
  '';

  nativeBuildInputs = [
    pkg-config
    python3
@@ -61,18 +82,6 @@ stdenv.mkDerivation {
    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"
  '';

  # Install udev rules in this package's out path:
  mesonFlags = [
    "-Dudevrulesdir=lib/udev/rules.d"
@@ -94,7 +103,7 @@ stdenv.mkDerivation {
    homepage = "https://github.com/carrotIndustries/usbkvm";
    description = "Open-source USB KVM (Keyboard, Video and Mouse) adapter";
    changelog = "https://github.com/carrotIndustries/usbkvm/releases/tag/v${version}";
    license = lib.licenses.gpl3;
    license = lib.licenses.gpl3Only;
    maintainers = with lib.maintainers; [ lschuermann ];
    mainProgram = "usbkvm";
  };