Skip to content

Commit

Permalink
[nix] compile my own xow with newer libusb
Browse files Browse the repository at this point in the history
  • Loading branch information
ttrei committed Feb 11, 2022
1 parent 2560ff6 commit f775d18
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 0 deletions.
5 changes: 5 additions & 0 deletions nix/home-manager/reinis/home.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
home.username = "reinis";
home.homeDirectory = "/home/reinis";

nixpkgs.overlays = [
(import overlays/mypackages.nix)
];

home.packages = with pkgs; [
direnv
emacs
Expand All @@ -15,6 +19,7 @@
git
git-crypt
ripgrep
myxow
];

programs.bash = {
Expand Down
5 changes: 5 additions & 0 deletions nix/home-manager/reinis/overlays/mypackages.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
self: super:
{
mylibusb1 = super.callPackage pkgs/mylibusb1 { };
myxow = super.callPackage pkgs/myxow { };
}
47 changes: 47 additions & 0 deletions nix/home-manager/reinis/overlays/pkgs/mylibusb1/default.nix
Original file line number Diff line number Diff line change
@@ -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 ];
};
}

46 changes: 46 additions & 0 deletions nix/home-manager/reinis/overlays/pkgs/myxow/default.nix
Original file line number Diff line number Diff line change
@@ -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;
};
}

0 comments on commit f775d18

Please sign in to comment.