Merge pull request #130625 from rski/openrazer

This commit is contained in:
Martin Weinelt 2021-08-07 15:32:04 +02:00 committed by GitHub
commit 4704dc2f1b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 45 additions and 7 deletions

View file

@ -646,6 +646,23 @@
to use wildcards in the <literal>source</literal> argument.
</para>
</listitem>
<listitem>
<para>
The <literal>openrazer</literal> and
<literal>openrazer-daemon</literal> packages as well as the
<literal>hardware.openrazer</literal> module now require users
to be members of the <literal>openrazer</literal> group
instead of <literal>plugdev</literal>. With this change, users
no longer need be granted the entire set of
<literal>plugdev</literal> group permissions, which can
include permissions other than those required by
<literal>openrazer</literal>. This is desirable from a
security point of view. The setting
<link xlink:href="options.html#opt-services.hardware.openrazer.users"><literal>harware.openrazer.users</literal></link>
can be used to add users to the <literal>openrazer</literal>
group.
</para>
</listitem>
</itemizedlist>
</section>
<section xml:id="sec-release-21.11-notable-changes">

View file

@ -164,6 +164,8 @@ pt-services.clipcat.enable).
- `programs.neovim.runtime` switched to a `linkFarm` internally, making it impossible to use wildcards in the `source` argument.
- The `openrazer` and `openrazer-daemon` packages as well as the `hardware.openrazer` module now require users to be members of the `openrazer` group instead of `plugdev`. With this change, users no longer need be granted the entire set of `plugdev` group permissions, which can include permissions other than those required by `openrazer`. This is desirable from a security point of view. The setting [`harware.openrazer.users`](options.html#opt-services.hardware.openrazer.users) can be used to add users to the `openrazer` group.
## Other Notable Changes {#sec-release-21.11-notable-changes}
- The setting [`services.openssh.logLevel`](options.html#opt-services.openssh.logLevel) `"VERBOSE"` `"INFO"`. This brings NixOS in line with upstream and other Linux distributions, and reduces log spam on servers due to bruteforcing botnets.

View file

@ -49,7 +49,9 @@ in
{
options = {
hardware.openrazer = {
enable = mkEnableOption "OpenRazer drivers and userspace daemon";
enable = mkEnableOption ''
OpenRazer drivers and userspace daemon.
'';
verboseLogging = mkOption {
type = types.bool;
@ -92,6 +94,15 @@ in
generate a heatmap.
'';
};
users = mkOption {
type = with types; listOf str;
default = [];
description = ''
Usernames to be added to the "openrazer" group, so that they
can start and interact with the OpenRazer userspace daemon.
'';
};
};
};
@ -106,10 +117,12 @@ in
services.udev.packages = [ kernelPackages.openrazer ];
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 = {};
# A user must be a member of the openrazer group in order to start
# the openrazer-daemon. Therefore we make sure that the group
# exists.
users.groups.openrazer = {
members = cfg.users;
};
systemd.user.services.openrazer-daemon = {
description = "Daemon to manage razer devices in userspace";

View file

@ -38,6 +38,10 @@ buildPythonApplication (common // rec {
setproctitle
];
postPatch = ''
substituteInPlace openrazer_daemon/daemon.py --replace "plugdev" "openrazer"
'';
postBuild = ''
DESTDIR="$out" PREFIX="" make install manpages
'';

View file

@ -30,11 +30,13 @@ stdenv.mkDerivation (common // {
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
--replace razer_mount $RAZER_MOUNT_OUT \
--replace plugdev openrazer
substituteInPlace $RAZER_MOUNT_OUT \
--replace /usr/bin/logger ${util-linux}/bin/logger \
--replace chgrp ${coreutils}/bin/chgrp \
--replace "PATH='/sbin:/bin:/usr/sbin:/usr/bin'" ""
--replace "PATH='/sbin:/bin:/usr/sbin:/usr/bin'" "" \
--replace plugdev openrazer
runHook postInstall
'';