diff --git a/modules/default.nix b/modules/default.nix index f39db14..afc24a8 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -24,5 +24,6 @@ desktop/pulseaudio.nix desktop/audio-rt.nix desktop/tailscale.nix + desktop/headsetcontrol.nix ]; } \ No newline at end of file diff --git a/modules/desktop/headsetcontrol.nix b/modules/desktop/headsetcontrol.nix new file mode 100644 index 0000000..fd63146 --- /dev/null +++ b/modules/desktop/headsetcontrol.nix @@ -0,0 +1,6 @@ +{ config, lib, pkgs, modulesPath, ... }: + +{ + environment.systemPackages = [ pkgs.headsetcontrol pkgs.headset-battery-indicator ]; + services.udev.packages = [ pkgs.headsetcontrol ]; # for udev rules +} diff --git a/overlays/pkgs.nix b/overlays/pkgs.nix index 870bb0f..5c98411 100644 --- a/overlays/pkgs.nix +++ b/overlays/pkgs.nix @@ -12,5 +12,6 @@ (final.lib.versionOlder prev.networkmanager.version "1.59") "nixpkgs now ships NetworkManager ${prev.networkmanager.version} >= 1.59 — remove the override in overlays/pkgs.nix and pkgs/networkmanager-dev/ if the patches are no longer needed"; prev.callPackage ../pkgs/networkmanager-dev/package.nix { }; + headset-battery-indicator = final.callPackage ../pkgs/headset-battery-indicator/package.nix { }; }) ] diff --git a/pkgs/headset-battery-indicator/package.nix b/pkgs/headset-battery-indicator/package.nix new file mode 100644 index 0000000..e6f6822 --- /dev/null +++ b/pkgs/headset-battery-indicator/package.nix @@ -0,0 +1,59 @@ +{ + lib, + python3Packages, + fetchFromGitHub, + qt6, + headsetcontrol, + xdg-utils, +}: + +python3Packages.buildPythonApplication rec { + pname = "headset-battery-indicator"; + version = "2.3.2"; + pyproject = true; + + src = fetchFromGitHub { + owner = "ruflas"; + repo = "headset-battery-indicator"; + tag = "v${version}"; + hash = "sha256-e9o8ECUjmu+G8OgEKjtshs1mFz4EXh30xrwL5Fx3lcQ="; + }; + + build-system = [ python3Packages.setuptools ]; + + dependencies = [ python3Packages.pyside6 ]; + + nativeBuildInputs = [ qt6.wrapQtAppsHook ]; + buildInputs = [ qt6.qtbase qt6.qtwayland ]; + + nativeCheckInputs = with python3Packages; [ pytestCheckHook pytest-qt ]; + preCheck = '' + export QT_QPA_PLATFORM=offscreen + export HOME=$(mktemp -d) + ''; + + postInstall = '' + install -Dm644 headset-battery-indicator.png \ + $out/share/icons/hicolor/512x512/apps/headset-battery-indicator.png + install -Dm644 headset-battery-indicator.desktop \ + $out/share/applications/headset-battery-indicator.desktop + ''; + + dontWrapQtApps = true; + preFixup = '' + makeWrapperArgs+=( + "''${qtWrapperArgs[@]}" + --prefix PATH : ${lib.makeBinPath [ headsetcontrol xdg-utils ]} + ) + ''; + + pythonImportsCheck = [ "headset_battery_indicator" ]; + + meta = { + description = "Tray indicator for wireless headset battery level, based on HeadsetControl"; + homepage = "https://github.com/ruflas/headset-battery-indicator"; + license = lib.licenses.gpl3Plus; + platforms = lib.platforms.linux; + mainProgram = "headset-battery-indicator"; + }; +}