-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
openrazer: init at 2.3.1 (driver, daemon, lib and NixOS module) #47009
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,160 @@ | ||
| { config, pkgs, lib, ... }: | ||
|
|
||
| with lib; | ||
|
|
||
| let | ||
| cfg = config.hardware.openrazer; | ||
|
|
||
| toPyBoolStr = b: if b then "True" else "False"; | ||
|
|
||
| daemonExe = "${cfg.daemonPackage}/bin/openrazer-daemon --config ${daemonConfFile}"; | ||
|
|
||
| daemonConfFile = pkgs.writeTextFile { | ||
| name = "razer.conf"; | ||
| text = '' | ||
| [General] | ||
| verbose_logging = ${toPyBoolStr cfg.verboseLogging} | ||
|
|
||
| [Startup] | ||
| sync_effects_enabled = ${toPyBoolStr cfg.syncEffectsEnabled} | ||
| devices_off_on_screensaver = ${toPyBoolStr cfg.devicesOffOnScreensaver} | ||
| mouse_battery_notifier = ${toPyBoolStr cfg.mouseBatteryNotifier} | ||
|
|
||
| [Statistics] | ||
| key_statistics = ${toPyBoolStr cfg.keyStatistics} | ||
| ''; | ||
| }; | ||
|
|
||
| dbusServiceFile = pkgs.writeTextFile rec { | ||
| name = "org.razer.service"; | ||
| destination = "/share/dbus-1/services/${name}"; | ||
| text = '' | ||
| [D-BUS Service] | ||
| Name=org.razer | ||
| Exec=${daemonExe} | ||
| SystemdService=openrazer-daemon.service | ||
| ''; | ||
| }; | ||
|
|
||
| drivers = [ | ||
| "razerkbd" | ||
| "razermouse" | ||
| "razerfirefly" | ||
| "razerkraken" | ||
| "razermug" | ||
| "razercore" | ||
| ]; | ||
| in | ||
| { | ||
| options = { | ||
| hardware.openrazer = { | ||
| enable = mkEnableOption "OpenRazer drivers and userspace daemon."; | ||
|
|
||
| daemonPackage = mkOption { | ||
| type = types.package; | ||
| default = pkgs.python3Packages.openrazer-daemon; | ||
| defaultText = "pkgs.python3Packages.openrazer-daemon"; | ||
| description = '' | ||
| Which package to use as the openrazer daemon. | ||
| ''; | ||
| }; | ||
|
|
||
| driverPackage = mkOption { | ||
| type = types.package; | ||
| default = config.boot.kernelPackages.openrazer; | ||
| defaultText = "config.boot.kernelPackages.openrazer"; | ||
| description = '' | ||
| Which package to use as the openrazer driver. | ||
| ''; | ||
| }; | ||
|
|
||
| kernelModules = mkOption { | ||
| type = types.listOf (types.enum drivers); | ||
| default = drivers; | ||
| description = '' | ||
| List of openrazer drivers to add as modules to the kernel. | ||
| ''; | ||
| }; | ||
|
|
||
| verboseLogging = mkOption { | ||
| type = types.bool; | ||
| default = false; | ||
| description = '' | ||
| Whether to enable verbose logging. Logs debug messages. | ||
| ''; | ||
| }; | ||
|
|
||
| syncEffectsEnabled = mkOption { | ||
| type = types.bool; | ||
| default = true; | ||
| description = '' | ||
| Set the sync effects flag to true so any assignment of | ||
| effects will work across devices. | ||
| ''; | ||
| }; | ||
|
|
||
| devicesOffOnScreensaver = mkOption { | ||
| type = types.bool; | ||
| default = true; | ||
| description = '' | ||
| Turn off the devices when the systems screensaver kicks in. | ||
| ''; | ||
| }; | ||
|
|
||
| mouseBatteryNotifier = mkOption { | ||
| type = types.bool; | ||
| default = true; | ||
| description = '' | ||
| Mouse battery notifier. | ||
| ''; | ||
| }; | ||
|
|
||
| keyStatistics = mkOption { | ||
| type = types.bool; | ||
| default = false; | ||
| description = '' | ||
| Collects number of keypresses per hour per key used to | ||
| generate a heatmap. | ||
| ''; | ||
| }; | ||
| }; | ||
| }; | ||
|
|
||
| config = mkIf cfg.enable { | ||
| boot.extraModulePackages = [ cfg.driverPackage ]; | ||
| boot.kernelModules = cfg.kernelModules; | ||
|
|
||
| # Makes the man pages available so you can succesfully run | ||
| # > systemctl --user help openrazer-daemon | ||
| environment.systemPackages = [ cfg.daemonPackage.man ]; | ||
|
|
||
| services.udev.packages = [ cfg.driverPackage ]; | ||
| services.dbus.packages = [ dbusServiceFile ]; | ||
|
|
||
| # A user must be a member of the plugdev group in order to start | ||
| # the openrazer-daemon. Therefore we make sure that the plugdev | ||
| # group exists. | ||
| users.groups = { plugdev = {}; }; | ||
|
|
||
| systemd.user.services = { | ||
| "openrazer-daemon" = { | ||
| description = "Daemon to manage razer devices in userspace"; | ||
| unitConfig.Documentation = "man:openrazer-daemon(8)"; | ||
| # Requires a graphical session so the daemon knows when the screensaver | ||
| # starts. See the 'devicesOffOnScreensaver' option. | ||
| wantedBy = [ "graphical-session.target" ]; | ||
| partOf = [ "graphical-session.target" ]; | ||
| serviceConfig = { | ||
| Type = "dbus"; | ||
| BusName = "org.razer"; | ||
| ExecStart = "${daemonExe} --foreground"; | ||
| Restart = "always"; | ||
| }; | ||
| }; | ||
| }; | ||
| }; | ||
|
|
||
| meta = { | ||
| maintainers = with lib.maintainers; [ roelvandijk ]; | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| { buildPythonApplication | ||
| , daemonize | ||
| , dbus-python | ||
| , fetchFromGitHub | ||
| , fetchpatch | ||
| , gobjectIntrospection | ||
| , gtk3 | ||
| , makeWrapper | ||
| , pygobject3 | ||
| , pyudev | ||
| , setproctitle | ||
| , stdenv | ||
| }: | ||
|
|
||
| let | ||
| openrazerSrc = import ./src.nix; | ||
| in | ||
| buildPythonApplication rec { | ||
| inherit (openrazerSrc) version; | ||
| pname = "openrazer_daemon"; | ||
|
|
||
| outputs = [ "out" "man" ]; | ||
|
|
||
| src = fetchFromGitHub openrazerSrc.github; | ||
| sourceRoot = "source/daemon"; | ||
| patches = [ | ||
| # https://github.com/openrazer/openrazer/pull/680 | ||
| (fetchpatch { | ||
| url = https://github.com/openrazer/openrazer/pull/680/commits/4d7078b6af0cf7de2e4ff0986daff73706ce7eb8.patch; | ||
| sha256 = "0v5bp3zw0csxr5day44gi6b38hm74hipbd7gvvain58b521br5fq"; | ||
| stripLen = 1; | ||
| }) | ||
|
|
||
| # https://github.com/openrazer/openrazer/pull/681 | ||
| (fetchpatch { | ||
| url = https://github.com/openrazer/openrazer/pull/681/commits/feefb86497af6ff7db827e682ae560c12d0aee2f.patch; | ||
| sha256 = "0vfwbdx252lz2v9mswi46jcrzd6pfyyxv1pn21l6a8as9gbakqrm"; | ||
| stripLen = 1; | ||
| }) | ||
| ]; | ||
|
|
||
| buildInputs = [ makeWrapper ]; | ||
|
|
||
| propagatedBuildInputs = [ | ||
| daemonize | ||
| dbus-python | ||
| gobjectIntrospection | ||
| gtk3 | ||
| pygobject3 | ||
| pyudev | ||
| setproctitle | ||
| ]; | ||
|
|
||
| preBuild = '' | ||
| make openrazer-daemon | ||
| ''; | ||
|
|
||
| postBuild = '' | ||
| DESTDIR="$out" PREFIX="" make manpages | ||
| ''; | ||
|
|
||
| # This fixes problems with gi.require_version('Gdk', '3.0') | ||
| preFixup = '' | ||
| wrapProgram $out/bin/openrazer-daemon \ | ||
| --prefix GI_TYPELIB_PATH : "$GI_TYPELIB_PATH" \ | ||
| --prefix LD_LIBRARY_PATH ":" "${gtk3.out}/lib" | ||
| ''; | ||
|
|
||
| meta = with stdenv.lib; { | ||
| description = "An entirely open source driver and user-space daemon that allows you to manage your Razer peripherals on GNU/Linux"; | ||
| homepage = https://openrazer.github.io/; | ||
| license = licenses.gpl2; | ||
| maintainers = with maintainers; [ roelvandijk ]; | ||
| platforms = platforms.linux; | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| { coreutils | ||
| , fetchFromGitHub | ||
| , kernel | ||
| , stdenv | ||
| , utillinux | ||
| }: | ||
|
|
||
| let | ||
| openrazerSrc = import ./src.nix; | ||
| in | ||
| stdenv.mkDerivation rec { | ||
| inherit (openrazerSrc) version; | ||
| name = "openrazer-${version}-${kernel.version}"; | ||
|
|
||
| src = fetchFromGitHub openrazerSrc.github; | ||
|
|
||
| nativeBuildInputs = kernel.moduleBuildDependencies; | ||
|
|
||
| buildFlags = [ | ||
| "KERNELDIR=${kernel.dev}/lib/modules/${kernel.version}/build" | ||
| ]; | ||
|
|
||
| installPhase = '' | ||
| binDir="$out/lib/modules/${kernel.modDirVersion}/kernel/drivers/hid" | ||
| mkdir -p "$binDir" | ||
| cp -v driver/*.ko "$binDir" | ||
|
|
||
| RAZER_MOUNT_OUT="$out/bin/razer_mount" | ||
| RAZER_RULES_OUT="$out/etc/udev/rules.d/99-razer.rules" | ||
|
|
||
| install -m 644 -v -D install_files/udev/99-razer.rules $RAZER_RULES_OUT | ||
| install -m 755 -v -D install_files/udev/razer_mount $RAZER_MOUNT_OUT | ||
|
|
||
| substituteInPlace $RAZER_RULES_OUT \ | ||
| --replace razer_mount $RAZER_MOUNT_OUT | ||
| substituteInPlace $RAZER_MOUNT_OUT \ | ||
| --replace /usr/bin/logger ${utillinux}/bin/logger \ | ||
| --replace chgrp ${coreutils}/bin/chgrp \ | ||
| --replace "PATH='/sbin:/bin:/usr/sbin:/usr/bin'" "" | ||
| ''; | ||
|
|
||
| meta = with stdenv.lib; { | ||
| description = "An entirely open source driver and user-space daemon that allows you to manage your Razer peripherals on GNU/Linux"; | ||
| homepage = https://openrazer.github.io/; | ||
| license = licenses.gpl2; | ||
| maintainers = with maintainers; [ roelvandijk ]; | ||
| platforms = platforms.linux; | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| { buildPythonPackage | ||
| , dbus-python | ||
| , fetchFromGitHub | ||
| , numpy | ||
| , stdenv | ||
| , openrazer-daemon | ||
| }: | ||
|
|
||
| let | ||
| openrazerSrc = import ./src.nix; | ||
| in | ||
| buildPythonPackage rec { | ||
| inherit (openrazerSrc) version; | ||
| pname = "openrazer"; | ||
|
|
||
| src = fetchFromGitHub openrazerSrc.github; | ||
| sourceRoot = "source/pylib"; | ||
|
|
||
| propagatedBuildInputs = [ | ||
| dbus-python | ||
| numpy | ||
| openrazer-daemon | ||
| ]; | ||
|
|
||
| meta = with stdenv.lib; { | ||
| description = "An entirely open source driver and user-space daemon that allows you to manage your Razer peripherals on GNU/Linux"; | ||
| homepage = https://openrazer.github.io/; | ||
| license = licenses.gpl2; | ||
| maintainers = with maintainers; [ roelvandijk ]; | ||
| platforms = platforms.linux; | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| rec { | ||
| version = "2.3.1"; | ||
| github = { | ||
| owner = "openrazer"; | ||
| repo = "openrazer"; | ||
| rev = "v${version}"; | ||
| sha256 = "0f8f4z89c16swfzhx73369rw097zgw7f1j1v84hnzqhwlzj256x2"; | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The expressions need to move under
pkgs/development/python-modules/*.Also, fix indentation.