From f775d188e103993e456105585289c4f72f60110f Mon Sep 17 00:00:00 2001 From: Reinis Taukulis Date: Fri, 11 Feb 2022 21:23:55 +0200 Subject: [PATCH] [nix] compile my own xow with newer libusb To avoid https://github.com/medusalix/xow/issues/141 --- nix/home-manager/reinis/home.nix | 5 ++ .../reinis/overlays/mypackages.nix | 5 ++ .../overlays/pkgs/mylibusb1/default.nix | 47 +++++++++++++++++++ .../reinis/overlays/pkgs/myxow/default.nix | 46 ++++++++++++++++++ 4 files changed, 103 insertions(+) create mode 100644 nix/home-manager/reinis/overlays/mypackages.nix create mode 100644 nix/home-manager/reinis/overlays/pkgs/mylibusb1/default.nix create mode 100644 nix/home-manager/reinis/overlays/pkgs/myxow/default.nix diff --git a/nix/home-manager/reinis/home.nix b/nix/home-manager/reinis/home.nix index 9c8eeb44..4342e198 100644 --- a/nix/home-manager/reinis/home.nix +++ b/nix/home-manager/reinis/home.nix @@ -6,6 +6,10 @@ home.username = "reinis"; home.homeDirectory = "/home/reinis"; + nixpkgs.overlays = [ + (import overlays/mypackages.nix) + ]; + home.packages = with pkgs; [ direnv emacs @@ -15,6 +19,7 @@ git git-crypt ripgrep + myxow ]; programs.bash = { diff --git a/nix/home-manager/reinis/overlays/mypackages.nix b/nix/home-manager/reinis/overlays/mypackages.nix new file mode 100644 index 00000000..d5d8ee66 --- /dev/null +++ b/nix/home-manager/reinis/overlays/mypackages.nix @@ -0,0 +1,5 @@ +self: super: +{ + mylibusb1 = super.callPackage pkgs/mylibusb1 { }; + myxow = super.callPackage pkgs/myxow { }; +} diff --git a/nix/home-manager/reinis/overlays/pkgs/mylibusb1/default.nix b/nix/home-manager/reinis/overlays/pkgs/mylibusb1/default.nix new file mode 100644 index 00000000..04a1d9d0 --- /dev/null +++ b/nix/home-manager/reinis/overlays/pkgs/mylibusb1/default.nix @@ -0,0 +1,47 @@ +{ lib, stdenv +, fetchFromGitHub +, fetchpatch +, autoreconfHook +, pkg-config +, enableUdev ? stdenv.isLinux && !stdenv.hostPlatform.isMusl +, udev +, withStatic ? false +}: + +stdenv.mkDerivation rec { + pname = "mylibusb"; + version = "1.0.25"; + + src = fetchFromGitHub { + owner = "libusb"; + repo = "libusb"; + rev = "v${version}"; + sha256 = "sha256-9ha22rlHFCrWYvcYKYAUlMC4aWMElDAgUPMxKePzPJA="; + }; + + outputs = [ "out" "dev" ]; + + nativeBuildInputs = [ pkg-config autoreconfHook ]; + propagatedBuildInputs = lib.optional enableUdev udev; + + dontDisableStatic = withStatic; + + configureFlags = lib.optional (!enableUdev) "--disable-udev"; + + preFixup = lib.optionalString enableUdev '' + sed 's,-ludev,-L${lib.getLib udev}/lib -ludev,' -i $out/lib/libusb-1.0.la + ''; + + meta = with lib; { + homepage = "https://libusb.info/"; + repositories.git = "https://github.com/libusb/libusb"; + description = "cross-platform user-mode USB device library"; + longDescription = '' + libusb is a cross-platform user-mode library that provides access to USB devices. + ''; + platforms = platforms.all; + license = licenses.lgpl21Plus; + maintainers = with maintainers; [ prusnak ]; + }; +} + diff --git a/nix/home-manager/reinis/overlays/pkgs/myxow/default.nix b/nix/home-manager/reinis/overlays/pkgs/myxow/default.nix new file mode 100644 index 00000000..dead2061 --- /dev/null +++ b/nix/home-manager/reinis/overlays/pkgs/myxow/default.nix @@ -0,0 +1,46 @@ +{ lib, stdenv, cabextract, fetchurl, fetchFromGitHub, mylibusb1 }: + +stdenv.mkDerivation rec { + pname = "myxow"; + version = "0.5"; + + src = fetchFromGitHub { + owner = "medusalix"; + repo = "xow"; + rev = "v${version}"; + sha256 = "071r2kx44k1sc49cad3i607xg618mf34ki1ykr5lnfx9y6qyz075"; + }; + + firmware = fetchurl { + url = "http://download.windowsupdate.com/c/msdownload/update/driver/drvs/2017/07/1cd6a87c-623f-4407-a52d-c31be49e925c_e19f60808bdcbfbd3c3df6be3e71ffc52e43261e.cab"; + sha256 = "013g1zngxffavqrk5jy934q3bdhsv6z05ilfixdn8dj0zy26lwv5"; + }; + + makeFlags = [ + "BUILD=RELEASE" + "VERSION=${version}" + "BINDIR=${placeholder "out"}/bin" + "UDEVDIR=${placeholder "out"}/lib/udev/rules.d" + "MODLDIR=${placeholder "out"}/lib/modules-load.d" + "MODPDIR=${placeholder "out"}/lib/modprobe.d" + "SYSDDIR=${placeholder "out"}/lib/systemd/system" + ]; + + postUnpack = '' + cabextract -F FW_ACC_00U.bin ${firmware} + mv FW_ACC_00U.bin source/firmware.bin + ''; + + enableParallelBuilding = true; + nativeBuildInputs = [ cabextract ]; + buildInputs = [ mylibusb1 ]; + + meta = with lib; { + homepage = "https://github.com/medusalix/xow"; + description = "Linux driver for the Xbox One wireless dongle"; + license = licenses.gpl2Plus; + maintainers = [ maintainers.jansol ]; + platforms = platforms.linux; + }; +} +