Skip to content

Instantly share code, notes, and snippets.

@piousdeer
Created December 21, 2022 01:17
Show Gist options
  • Save piousdeer/873a55e3a907c6ca52376dbcfd629384 to your computer and use it in GitHub Desktop.
Save piousdeer/873a55e3a907c6ca52376dbcfd629384 to your computer and use it in GitHub Desktop.
{ lib
, fetchFromGitHub
, rustPlatform
, pkg-config
, dbus
, xorg
, pango
, cairo
, libusb
, libvpx
, libyuv
, git
, cmake
, writeText
, llvmPackages
}:
rustPlatform.buildRustPackage rec {
pname = "legion-kb-rgb";
version = "0.18.0";
src = fetchFromGitHub {
owner = "4JX";
repo = "L5P-Keyboard-RGB";
rev = "v${version}";
hash = "sha256-NS65GaqF77JKFPiMC7ut40E1BW6id2k0bCAUtVPTXNw=";
};
cargoHash = "sha256-Tt5k/0CxxXPmMBJ1SUSadqUNmVBg4YUXCIu/+wF+9Tc";
# Manually simulate a vcpkg installation so that it can link the libaries
# properly. Borrowed from: https://github.com/NixOS/nixpkgs/blob/69a35ff92dc404bf04083be2fad4f3643b2152c9/pkgs/applications/networking/remote/rustdesk/default.nix#L51
postUnpack =
let
vcpkg_target = "x64-linux";
updates_vcpkg_file = writeText "update_vcpkg_legion-kb-rgb"
''
Package : libyuv
Architecture : ${vcpkg_target}
Version : 1.0
Status : is installed
Package : libvpx
Architecture : ${vcpkg_target}
Version : 1.0
Status : is installed
'';
in
''
export VCPKG_ROOT="$TMP/vcpkg"
mkdir -p $VCPKG_ROOT/.vcpkg-root
mkdir -p $VCPKG_ROOT/installed/${vcpkg_target}/lib
mkdir -p $VCPKG_ROOT/installed/vcpkg/updates
ln -s ${updates_vcpkg_file} $VCPKG_ROOT/installed/vcpkg/status
mkdir -p $VCPKG_ROOT/installed/vcpkg/info
touch $VCPKG_ROOT/installed/vcpkg/info/libyuv_1.0_${vcpkg_target}.list
touch $VCPKG_ROOT/installed/vcpkg/info/libvpx_1.0_${vcpkg_target}.list
ln -s ${libvpx.out}/lib/* $VCPKG_ROOT/installed/${vcpkg_target}/lib/
ln -s ${libyuv.out}/lib/* $VCPKG_ROOT/installed/${vcpkg_target}/lib/
'';
LIBCLANG_PATH = "${llvmPackages.libclang.lib}/lib";
buildInputs = [
dbus
xorg.libXinerama
xorg.libXcursor
xorg.libXfixes
pango
cairo
libusb
libvpx
libyuv
];
nativeBuildInputs = [
pkg-config
git
cmake
llvmPackages.clang
];
meta = with lib; {
description = "Cross-platform software to control the lighting of the 4 zone keyboard included in the 2020 and 2021 lineup of the Lenovo Legion laptops";
homepage = "https://github.com/4JX/L5P-Keyboard-RGB";
license = licenses.gpl3;
# maintainers = [ maintainers.tailhook ];
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment