From cf5dd2623bb5518257d0edbb50a84093f08086bb Mon Sep 17 00:00:00 2001 From: Michael Weiss Date: Thu, 24 Oct 2019 14:54:40 +0200 Subject: [PATCH 1/2] brightnessctl: Add systemd support This makes it possible to use brightnessctl without udev rules / suid. --- pkgs/misc/brightnessctl/default.nix | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkgs/misc/brightnessctl/default.nix b/pkgs/misc/brightnessctl/default.nix index fc4468921290..387216e052f9 100644 --- a/pkgs/misc/brightnessctl/default.nix +++ b/pkgs/misc/brightnessctl/default.nix @@ -1,4 +1,4 @@ -{ stdenv, fetchFromGitHub, coreutils }: +{ stdenv, fetchFromGitHub, coreutils, pkg-config, systemd }: stdenv.mkDerivation rec { pname = "brightnessctl"; @@ -11,12 +11,17 @@ stdenv.mkDerivation rec { sha256 = "0immxc7almmpg80n3bdn834p3nrrz7bspl2syhb04s3lawa5y2lq"; }; - makeFlags = [ "PREFIX=" "DESTDIR=$(out)" ]; + makeFlags = [ "PREFIX=" "DESTDIR=$(out)" "ENABLE_SYSTEMD=1" ]; postPatch = '' substituteInPlace 90-brightnessctl.rules --replace /bin/ ${coreutils}/bin/ + # For backward compatibility with the NixOS module / udev approach: + substituteInPlace Makefile --replace "INSTALL_UDEV_RULES=0" "INSTALL_UDEV_RULES=1" ''; + nativeBuildInputs = [ pkg-config ]; + buildInputs = [ systemd ]; + meta = with stdenv.lib; { homepage = "https://github.com/Hummer12007/brightnessctl"; description = "This program allows you read and control device brightness"; From 5282bc9a748b1dbf2da2a450f522fdbbff192780 Mon Sep 17 00:00:00 2001 From: Michael Weiss Date: Mon, 10 Feb 2020 23:10:53 +0100 Subject: [PATCH 2/2] nixos/brightnessctl: Remove the module Due to the support of the systemd-logind API the udev rules aren't required anymore which renders this module useless [0]. Note: brightnessctl should now require a working D-Bus setup and a valid local logind session for this to work. [0]: https://github.com/NixOS/nixpkgs/pull/79663 --- nixos/modules/hardware/brightnessctl.nix | 31 ------------------------ nixos/modules/module-list.nix | 1 - nixos/modules/rename.nix | 6 +++++ pkgs/misc/brightnessctl/default.nix | 8 +----- 4 files changed, 7 insertions(+), 39 deletions(-) delete mode 100644 nixos/modules/hardware/brightnessctl.nix diff --git a/nixos/modules/hardware/brightnessctl.nix b/nixos/modules/hardware/brightnessctl.nix deleted file mode 100644 index 2d54398d10df..000000000000 --- a/nixos/modules/hardware/brightnessctl.nix +++ /dev/null @@ -1,31 +0,0 @@ -{ config, lib, pkgs, ... }: - -with lib; -let - cfg = config.hardware.brightnessctl; -in -{ - - options = { - - hardware.brightnessctl = { - - enable = mkOption { - default = false; - type = types.bool; - description = '' - Enable brightnessctl in userspace. - This will allow brightness control from users in the video group. - ''; - - }; - }; - }; - - - config = mkIf cfg.enable { - services.udev.packages = with pkgs; [ brightnessctl ]; - environment.systemPackages = with pkgs; [ brightnessctl ]; - }; - -} diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 402f222f4e92..9bad1554adc9 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -41,7 +41,6 @@ ./hardware/acpilight.nix ./hardware/all-firmware.nix ./hardware/bladeRF.nix - ./hardware/brightnessctl.nix ./hardware/brillo.nix ./hardware/ckb-next.nix ./hardware/cpu/amd-microcode.nix diff --git a/nixos/modules/rename.nix b/nixos/modules/rename.nix index 3b1b1b8bb55c..2cc6c46e3581 100644 --- a/nixos/modules/rename.nix +++ b/nixos/modules/rename.nix @@ -42,6 +42,12 @@ with lib; instead, or any other display manager in NixOS as they all support auto-login. '') (mkRemovedOptionModule [ "services" "dnscrypt-proxy" ] "Use services.dnscrypt-proxy2 instead") + (mkRemovedOptionModule ["hardware" "brightnessctl" ] '' + The brightnessctl module was removed because newer versions of + brightnessctl don't require the udev rules anymore (they can use the + systemd-logind API). Instead of using the module you can now + simply add the brightnessctl package to environment.systemPackages. + '') # Do NOT add any option renames here, see top of the file ]; diff --git a/pkgs/misc/brightnessctl/default.nix b/pkgs/misc/brightnessctl/default.nix index 387216e052f9..37956785a5bb 100644 --- a/pkgs/misc/brightnessctl/default.nix +++ b/pkgs/misc/brightnessctl/default.nix @@ -1,4 +1,4 @@ -{ stdenv, fetchFromGitHub, coreutils, pkg-config, systemd }: +{ stdenv, fetchFromGitHub, pkg-config, systemd }: stdenv.mkDerivation rec { pname = "brightnessctl"; @@ -13,12 +13,6 @@ stdenv.mkDerivation rec { makeFlags = [ "PREFIX=" "DESTDIR=$(out)" "ENABLE_SYSTEMD=1" ]; - postPatch = '' - substituteInPlace 90-brightnessctl.rules --replace /bin/ ${coreutils}/bin/ - # For backward compatibility with the NixOS module / udev approach: - substituteInPlace Makefile --replace "INSTALL_UDEV_RULES=0" "INSTALL_UDEV_RULES=1" - ''; - nativeBuildInputs = [ pkg-config ]; buildInputs = [ systemd ];