sc-controller: fix udev for NixOS

This commit is contained in:
rnhmjoj 2018-08-21 10:56:52 +02:00
parent 81b681c0f5
commit 5914624410
No known key found for this signature in database
GPG key ID: 91BE884FBA4B591A
2 changed files with 26 additions and 2 deletions

View file

@ -2,7 +2,7 @@
, gtk3, gobjectIntrospection, libappindicator-gtk3, librsvg
, evdev, pygobject3, pylibacl, pytest
, linuxHeaders
, libX11, libXext, libXfixes, libusb1
, libX11, libXext, libXfixes, libusb1, libudev
}:
buildPythonApplication rec {
@ -24,12 +24,14 @@ buildPythonApplication rec {
checkInputs = [ pytest ];
patches = [ ./fix-udev.patch ];
postPatch = ''
substituteInPlace scc/paths.py --replace sys.prefix "'$out'"
substituteInPlace scc/uinput.py --replace /usr/include ${linuxHeaders}/include
'';
LD_LIBRARY_PATH = lib.makeLibraryPath [ libX11 libXext libXfixes libusb1 ];
LD_LIBRARY_PATH = lib.makeLibraryPath [ libX11 libXext libXfixes libusb1 libudev ];
preFixup = ''
gappsWrapperArgs+=(--prefix LD_LIBRARY_PATH : "$LD_LIBRARY_PATH")

View file

@ -0,0 +1,22 @@
diff --git a/scc/lib/eudevmonitor.py b/scc/lib/eudevmonitor.py
index 6c1bd18..182eff2 100644
--- a/scc/lib/eudevmonitor.py
+++ b/scc/lib/eudevmonitor.py
@@ -28,12 +28,11 @@ class Eudev:
def __init__(self):
self._ctx = None
- self._lib = ctypes.CDLL(find_library(self.LIB_NAME))
- if self._lib is None:
- # Alternative approach for NixOS
- try:
- self._lib = ctypes.cdll.LoadLibrary("libudev.so")
- except OSError:
+ try:
+ self._lib = ctypes.cdll.LoadLibrary("libudev.so")
+ except OSError:
+ self._lib = ctypes.CDLL(find_library(self.LIB_NAME))
+ if self._lib is None:
raise ImportError("No library named udev")
Eudev._setup_lib(self._lib)
self._ctx = self._lib.udev_new()